a question about window.open

Discussion in 'JavaScript' started by progfrog, Feb 8, 2008.

  1. #1
    hi
    there is something i don't understand with this argument :
    var imgL=window.open(pic1.src,"imgL","width=320,height=240");

    it sepose to open a picture in a new window but why is it diffrent than window.alert();?
    why do we need a var for it and why do we need to call the var again in the ()?
    It isn't my code that is why i don't understand it..


    please answer....:eek:
     
    progfrog, Feb 8, 2008 IP
  2. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Heh, lets see, where to start. . . Well, why is it different from window.alert()? Window.alert() can only produce that small dialog box with the 'Okay' button on it. The window.open() command actually create a real browser window that opens a web page, or in your case a picture.

    And why do we need a variable for it? You don't, it's not necessary, but the open command does return a reference pointer for the window you just created, so if you wanted to call it's moveTo() or moveBy() functions you could- like imgL.focus();

    And by call the variable again you are talking about the "imgL" inside of the method parameters, right? That isn't the variable, it's a string being passes to the open() method, and that string will be the windows title. Here is the open command and it's method statments:

    open(URL, windowName[, windowFeatures])

    To learn more about the open() function:
    http://www.javascript-coder.com/window-popup/javascript-window-open.phtml

    Or check this out for more methods you can do from the window class:
    http://www.comptechdoc.org/independent/web/cgi/javamanual/javawindow.html
     
    ToddMicheau, Feb 8, 2008 IP