4 Replies Latest reply on Oct 24, 2007 9:45 AM by Greg Dove

    Change Html Title dynamic from Flash

    luciewong Level 1
      Hi,
      I want to change the Title of the Html page dynamically from the embedded Flash.
      The Title, that appears on Browser bars etc.
      Could I do this?

      On init I can load the Html source code in with LoadVars, and onData (src) change the Title with subString method, but, how then could I pass the new value back to the Html page, so the Browser Title changes?

      Thank you.
      Luciewong

        • 1. Re: Change Html Title dynamic from Flash
          Greg Dove Level 4
          You don't need to load the html source code.

          You would normally do this with javascript via ExternalInterface. Something like the following:
          var newTitle ="my new page title";
          if (ExternalInterface.available) {
          ExternalInterface.call("setDocTitle",newTitle);

          }

          and in your page/html

          <script type="text/javascript">
          function setDocTitle(newTitle){
          top.document.title=newTitle;

          }
          </script>

          There is no guarantee that this will work though.. it depends on the browser.

          • 2. Re: Change Html Title dynamic from Flash
            Level 7
            You'll need to do it using JavaScript (look up document.title). You can call
            a JS function, on your page, using the ExternalInterface class.

            --
            Dave -
            Head Developer
            http://www.blurredistinction.com
            Adobe Community Expert
            http://www.adobe.com/communities/experts/


            • 3. Re: Change Html Title dynamic from Flash
              luciewong Level 1
              Thank you both GWD and Dave for the help.
              I know your code works under normal circumstances, just in my case, I can't get it to work.
              Because, on a subsequent Frame, called after the ExternalInterface.call,
              I have a getURL(javascript) to change the doc. background color.
              Now, either the Title changes or the background color changes, but both after each other, can't make it.
              I have tried Ext,CallBack function, so when the Title changes and callBack is true, move on, but still then it changes the BG, but not the title anymore.

              I must do something wrong with the callBack function?
              Thank you for your help.
              Regards,
              Luciewong
              • 4. Re: Change Html Title dynamic from Flash
                Greg Dove Level 4
                I've used getURL before ExternalInterface but never the other way around. I don't know if that's relevant to your problem or not though.

                I would use ExternalInterface for both requests and have a function in the page which you call from flash to change the background colour also. Try that approach and see if it works.