View Full Version : changing HTML Title
sankey
11-03-2004, 04:47 PM
Hi, I'm using flash as the GUI, and I would like to change the HTML title, when i move from one frame to another. I have the javascript and it works fine:
JS:
function updateTitle(newTitle){
//alert(newTitle);
document.title = newTitle;
}
As you can see i have an alert commented out. If i use the alert I can see i get the newTitle from flash, however when I try to use the javascript to update the page title, nothign happends.
When i use the javascript in a regular HTML page, the javascript works fine.
Actionscript in file:
function updateTitle(newTitle){
getURL("javascript: updateTitle('"+newTitle+"')");
}
updateTitle("test");
I've tried adding "_self" to the getURL call, all that does is replace my page with the getURL call.
Gibberish
11-03-2004, 04:53 PM
have you tried sendAndLoad() insted of getURL();
Actionscript in file:
function updateTitle(newTitle){
sendAndLoad("javascript: updateTitle('"+newTitle+"')",this,"POST");
}
updateTitle("test");
this works for me:
this.getURL("javascript: window.document.title='Set Title'; void(0);");
or to better match your example:
this.getURL("javascript: window.document.title='"+newTitle+"'; void(0);");
this way you don't even need the javascript(in your html document) part of the whole thing.
sankey
11-04-2004, 06:25 PM
sad to say it didn't work. I even tried it in a blank flash file on the first frame. I'm using Flash MX2004, and IE 6.0.29 with SP2
sankey
11-05-2004, 02:08 PM
ok, so i installed Mozilla, and it works great. Apparently it's something with IE... Odd, casue I am able to manipulate the title outside of Flash, perhaps some sort of active-x violation? ohh well, thanks for the help.
CookieDog
11-05-2004, 03:40 PM
This will change the title for you, and works in IE:
Put this in your Flash .swf on your button or wherever you are triggering your page change from:
fscommand("changeTitle",newTitle);
Put this in your HTML doc as Javascript:
// Name of function has to correspond to ID value of .swf file embedded
// within this HTML page, 'mySwf' part of 'mySwf_DoFSCommand' is .swf ID
function mySwf_DoFSCommand(command, args) {
var mainObj = InternetExplorer ? main : document.main;
// CHANGE HTML PAGE TITLE FROM FLASH FILE
if (command == "changeTitle") {
document.title = args;
}
}
sankey
11-05-2004, 04:22 PM
awesome! only had to change you line for the main object to:
var mainObj = isInternetExplorer ? document.all.swfID : document.swfID;
CookieDog
11-05-2004, 07:27 PM
Oops! Sorry, I forgot to change that part. My .swf ID was "main", but it should be changed to whatever your .swf ID is, which you already figured out. And that line is related to this line that I forgot to include (it assigns the value to 'InternetExplorer'):
This line is outside of the mySwf_DoFSCommand function, and before it:
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
Anyway, glad you got it working!
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.