4 Replies Latest reply on Oct 20, 2009 11:00 AM by yevri

    Dynamic URL with JavaScript

    yevri Level 1

      I use this script to launch a url in a pop-up window:

       

      getURL("javascript:openNewWindow('contact.html','thewin','width=700,height=400,toolbar=yes ,scrollbars=yes') ");

       

      I want to be able to make the URL dynamic, but when I try it with the JavaScript sizing the window, I can't get it to work. What should I be doing?

       

      This one works, but not sizing the window:

      getURL("contact/" +_root.agent+ ".html","_blank");

       

      Thanks,

       

      Brian

        • 1. Re: Dynamic URL with JavaScript
          Adamcbrz Level 2

          You need to look at flash's ExternalInterface Documentation (http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001036.html)

           

          With ExternalInterface you could do something like:

           

          import flash.external.*;
          var url = "contact/" +_root.agent+ ".html";
          ExternalInterface.call("openNewWindow", url);

           

          This will call your javascript function and you can do the rest in javascript.

           

          An alternate solution is to continue to use the getURL function:

           

          getURL("javascript:openNewWindow('contact/" +_root.agent+ ".html"','thewin','width=700,height=400,t oolbar=yes,scrollbars=yes') ");

           

          That would accomplish the same thing.

           

          If that is not what you are trying to accomplish let me know and I we can try to figure the miscommunication.

           

          Thanks,

          Adam

          • 2. Re: Dynamic URL with JavaScript
            yevri Level 1

            Thanks for the help. Makes sense. Trying to continue to use the getURL function using:

            on (release) {

            getURL("javascript:openNewWindow('contact/" +_root.agent+ ".html"','thewin','width=700,height=400,toolbar=yes,scrollbars=yes') ");

            }

             

            I get an error saying unexpected ")" and it says syntax error.

             

            the ); and } at the end are green, which tells me something is wrong - as if the quotes are set up wrong because of single quotes, etc.

             

            That's what was happening to me from the start. What in that line of code is wrong?

            • 3. Re: Dynamic URL with JavaScript
              Adamcbrz Level 2

              You have an extra " after .html

               

              You can see where the quote in red below:

               

              getURL("javascript:openNewWindow('contact/" +_root.agent+ ".html"','thewin','width=700,height=400,toolbar=yes,scrollbars=yes')");

              • 4. Re: Dynamic URL with JavaScript
                yevri Level 1

                Thanks. That did it. I appreciate the help.