Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > HTML and JavaScript

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-03-2004, 04:47 PM   #1
sankey
Registered User
 
Join Date: Mar 2003
Posts: 15
Default changing HTML Title

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.
sankey is offline   Reply With Quote
Old 11-03-2004, 04:53 PM   #2
Gibberish
WHAT!?
 
Join Date: Aug 2004
Location: San Diego, CA
Posts: 1,774
Default

have you tried sendAndLoad() insted of getURL();

PHP Code:
Actionscript in file:
function 
updateTitle(newTitle){
sendAndLoad("javascript: updateTitle('"+newTitle+"')",this,"POST"); 
}

updateTitle("test"); 
Gibberish is offline   Reply With Quote
Old 11-03-2004, 05:55 PM   #3
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,048
Default

this works for me:
Code:
this.getURL("javascript: window.document.title='Set Title'; void(0);");
or to better match your example:
Code:
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.
__________________
tg
---
what the hell was i thinking?

Last edited by tg; 11-03-2004 at 05:57 PM..
tg is offline   Reply With Quote
Old 11-04-2004, 06:25 PM   #4
sankey
Registered User
 
Join Date: Mar 2003
Posts: 15
Default

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 is offline   Reply With Quote
Old 11-05-2004, 02:08 PM   #5
sankey
Registered User
 
Join Date: Mar 2003
Posts: 15
Default

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.
sankey is offline   Reply With Quote
Old 11-05-2004, 03:40 PM   #6
CookieDog
CookieDog
 
Join Date: Oct 2004
Posts: 107
Default

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:
Quote:
// 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;
}

}
CookieDog is offline   Reply With Quote
Old 11-05-2004, 04:22 PM   #7
sankey
Registered User
 
Join Date: Mar 2003
Posts: 15
Default

awesome! only had to change you line for the main object to:

var mainObj = isInternetExplorer ? document.all.swfID : document.swfID;
sankey is offline   Reply With Quote
Old 11-05-2004, 07:27 PM   #8
CookieDog
CookieDog
 
Join Date: Oct 2004
Posts: 107
Default

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!
CookieDog is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:00 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.