A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Change browser window title...

  1. #1
    Senior Member
    Join Date
    Jul 2004
    Posts
    264

    Question 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!

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Works fine here (mac Safari, Firefox, Opera, Chrome). Didn't test it on PC IE. Could be a browser issue.

    gparis

  3. #3
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    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).

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    There's always something different happening with IE. Whichever version on whatever case. Can't believe they still get away with it.

    gparis

  5. #5
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    This one was really frustrating...
    Especially because some people say it works... well... not for me

  6. #6
    Senior Member
    Join Date
    Jul 2004
    Posts
    264

    Thumbs down

    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.

  7. #7
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    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.

  8. #8
    Senior Member
    Join Date
    Jul 2004
    Posts
    264
    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.

  9. #9
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center