-
Change browser window title...
Hi guys,
I cannot seem to get the following to work:
In flash (as2):
Actionscript Code:
getURL("JavaScript:changeTitle('Hello!')");
in browser:
PHP Code:
<script language="javascript">
<!--
function changeTitle(t){
document.title = t;
alert("changed!" + t)
}
-->
</script>
The result is - the page title stays the same, there are no errors - but i do get an alert that says "changed! Hello!" So the function is being fired, and the variable is being sent. It just will not change the page title.
If i call the function in javascript - so just under the function add - changeTitle("good") - it works fine, changing the title.
It must be from where the function is being called?
i have also tried window.document.title - and that is no good either.
Thanks for any help!
-
Works fine here (mac Safari, Firefox, Opera, Chrome). Didn't test it on PC IE. Could be a browser issue.
gparis
-
Registered User
hi,
On pc, works fine for me in FF and Chrome.
It doesn't work in IE 8.
I tried JavaScript, jQuery and SWFAddress. No luck. (although the SWFAddress example works).
-
There's always something different happening with IE. Whichever version on whatever case. Can't believe they still get away with it.
gparis
-
Registered User
This one was really frustrating...
Especially because some people say it works... well... not for me
-
Cheers guys.
Yeah, i cannot work it out - and i've tried lots of different ways. 
What i cannot understand is that it just appears to be the "title" you cannot change.
This example changes the page background with javascript and flash. HERE
The js function is basically just this:
PHP Code:
function backgroundColor(newBgColor){
document.bgColor = newBgColor;
}
So that is flash using "document".
So why will "document.title" not work, if "document.bgColor" will?
Could it be for some reason ie8 loads the page title last? And after flash has updated the title, the original title overwrites it?
Maybe setting the variable from flash as a js variable - and then using "window.onload = function() " to rechange the title when everything is ready?
I am going to try this when i get home from work.
edit:
nunomira -- thanks for trying the different libs! I will try swfaddress when i get home as well. But it seems a bit of a waste using a libary just to change the title. I will look in swfaddress and see what it does to change it if it works. Thanks!
Last edited by itsallgood; 07-30-2010 at 08:18 AM.
-
Registered User
Could it be for some reason ie8 loads the page title last? And after flash has updated the title, the original title overwrites it?
No, in my example I would click on the stage in order to change the title. It didn't work.
I tried SWFAddress, but JavaScript only, i.e., I called SWFAddress.setTitle() directly inside your changeTitle() function.
I've always used SWFAddress from Flash with success.
-
This is 100% just an internet explorer bug - does anyone know where you can report ie8 bugs? I've spent about 20mins just going around in circles trying to find out how to report a problem!!!
They make it sooooo damn hard to report problems with their garbage software!
Why would i want to fill out 4 pages of person info just to let them know about this problem?
-------
I've found out, by puting an "alert" in the fuction, ie8 actually thinks it is changing the page title - it just dosnt update it.
on(release){
getURL("javascript:changeTitle('Flash Title')");
}
PHP Code:
<script language="javascript">
<!--
function changeTitle(what){
document.title = what
alert(document.title)
}
changeTitle("New Title")
-->
</script>
When you load the page - you get the alert "New Title"
When you click the button in flash you get "Flash Title"
So the browser actually thinks the title has changed. It just hasnt!
If you add this line in the function:
PHP Code:
<script language="javascript">
<!--
function changeTitle(what){
window.location.hash = '' // THIS LINE HERE
document.title = what
alert(document.title)
}
changeTitle("New Title")
-->
</script>
The page title updates to the new title! But you are left with a "#" at the end of the urls. AND as soon as you click the swf on the page - the title reverts back to the old one.
Last edited by itsallgood; 07-31-2010 at 09:17 AM.
-
Registered User
IE sucks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|