A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Javascript Window within Javascript Window - is it possible?!?

  1. #1
    Dazed & Confused! purplebutterfly's Avatar
    Join Date
    Nov 2002
    Location
    South Florida
    Posts
    107

    Javascript Window within Javascript Window - is it possible?!?

    I posted about this once before but I'm still having a problem with it...maybe someone else has figured this out!

    OK....here is what I am trying to do:
    My website begins with a static HTML page that contains an "enter" link. The "enter" link opens a .swf file in a new window using the following code:

    on (release) {
    getURL("javascript:NewWindow=window.open('HomePage .swf','newWin','width=800,height=600,scale=showall ,left=0,top=0,toolbar=No,location=No,scrollbars=No ,status=No,resizable=Yes,fullscreen=No'); NewWindow.focus(); void(0);");
    }

    The Flash movie 'HomePage.swf' has various Movie clips on the main timeline that are the different 'pages' of my online portfolio...Home, Links, Contact Info, Gallery, etc. In the "Gallery" is a button for "Photography" that links to my slideshow. What I want to do is to apply the same code to the "Photography" button as the one above that is on the "enter" button. I want my slideshow to open in a new, separate window that is 550x450, not resizeable, with no toolbars/scrollbars. However, when I apply the code to the "Photography" button and test the movie, a window opens to the correct dimensions but it stays copletely white, then my cursor begins to flash rapidly, and then I have to use the Task Manager to close the window as it locks up the computer! Help!

    Also, what is the code to open a new window in the center of the full screen? I know that, for example, "left=0,top=0" will open the window in the upper left corner, but don't know what the middle is!

    Thanks in advance for any help or advice anyone can give me!
    Tulane

  2. #2
    Flashkit Jedi

    Join Date
    Jul 2001
    Location
    Coruscant System
    Posts
    3,426
    Testing the movie from the Test Movie command within Flash?

    Try testing it by opening the actual html page.

    XFM

  3. #3
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    To open in the centre of the screen you could create a function in the html page that finds out the screen resolution and then works out the required position given the width and height of the window.

    However in MX, this can now be easily brought inside the movie,

    code:

    // action in the main timeline of your movie
    // create a function that can be called from any clip
    // to launch a centred window with a given a file to open,
    // a name for the new window and the width and height
    MovieClip.prototype.openWindow = function(file, name, width, height) {
    var x = (System.capabilities.screenResolutionX - width) / 2; // find the x position for the window
    var y = (System.capabilities.screenResolutionY - height) / 2; // and the y position, then call the getURL using these values
    getURL("javascript:window.open('" + file + "','" + name + "','width=" + width + ",height=" + height + ",left=" + x + ",top=" + y + ",screenX=" + x + ",screenY=" + y + "');void(0);");
    };



    This can then be called using something like,
    code:

    on (press) {
    this.openWindow("filename.html", "newWindowName", 400, 300); // create a 400 by 300 window
    }



    Edit] Also make sure that if you already have a popup window open you use a different name for any other popups you create.

  4. #4
    Dazed & Confused! purplebutterfly's Avatar
    Join Date
    Nov 2002
    Location
    South Florida
    Posts
    107
    Also make sure that if you already have a popup window open you use a different name for any other popups you create.
    Do you mean a different name for the .swf that I am calling, or is there a variable in the Javascript that I should be different?

  5. #5
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    when you create the window using window.open it is common to use three arguments,

    the filename of the page to open, the window name and window decorations,

    eg

    window.open('myfile.html','newWin','width=400,height=500');

    highlighted in bold is the window name.

    If a window is already open with the name newWin (or whatever) and you tried to open another one with the same name. instead of creating a second new window, the window that is there already will be replaced.

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