Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing vars to javascript window.open()

    hi,

    I want to pass window size variables to javascript's window.open() function from a flash movie (actionscript) to javascript embedded in an html page. The idea is to generate a pop-up window when the user clicks a button in the flash movie. I've programmed the flash movie button like this:

    on (release) {
    getURL("javascript:open_win('http://www.mysite.com', winfeatures)"); }

    where winfeatures is a string containing the pop-up window options, e.g. width=400,height=300,resizable=1 . I have 'traced' the string to make sure it is formed properly. These variables may change so I don't want to just insert them verbatim as the arguments. They are read from an xml file and made into a string - e.g. (var winfeatures:String = "width="+myxml.attributes.width+",height="+myxml.attributes.height);

    In the html page I have the following javascript:

    <SCRIPT LANGUAGE=JavaScript>
    function open_win(URLtoOpen, windowFeatures) {
    newWindow=window.open(URLtoOpen, "myWin", windowFeatures);
    }
    </SCRIPT>

    but it's not working. It seems the windowFeatures isn't being read (or read properly) and the pop-up opens with a default size.

    Can anyone tell me what I'm doing wrong?

    Thanks!

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Flash will not recognize a variable inside of a string like that, try this.

    Code:
    on (release) {
    getURL("javascript:open_win('http://www.mysite.com', " + winfeatures + ")"); }
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #3
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Jeremy - thanks for your quick reply. Unfortunately though, it's still not working - it still opens the pop window with a default size.

    Could it be the formation of the winfeatures string in the actionscript? This is how I form it:
    winfeatures = "height="+myxml[0].attributes.height+",width="+myxml[0].attributes.width+",resizable=1,scrollbars=1";

    Or am I perhaps missing something on the javascript in the html page?

    Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •