Mega Code Archive

 
Categories / JavaScript Tutorial / Window
 

Window open()

Syntax window.open(pageURL, name, parameters) The open() method creates a new instance of a window. It loads the pageURL. The ACTION attribute of the tag and the TARGET attribute of the tag can reference the window. You must use comma to separate each of these options and do not insert any spaces. Parameters That Can Be Passed When Creating a New Window ParameterInitialize WithDescription alwaysLoweredyes/notells the window to stay behind all other windows. This must be done in signed scripts. alwaysRaisedyes/notells the window to stay on top of all other windows. This must be done in signed scripts. dependentyes/noopens the window as a true child window of the parent window. directoriesyes/noSpecifies if the Directory Bar on Navigator 2 and 3 is visible. heightpixel valueSets the height of the window. hotkeysyes/noDisables all but the Security and Quit hotkeys in a new window with no Menu Bar. innerHeightpixel valueSets the height of the document. innerWidthpixel valueSets the width of the document. locationyes/noSpecifies if the Location Bar is visible. menubaryes/noSpecifies if the Menu Bar is visible. outerHeightpixel valueSets the height of the window, including the chrome. outerWidthpixel valueSets the width of the window, including the chrome. resizableyes/noSpecifies if the window can be resized. screenXpixel valueSets the distance of the window from the left side of the screen. screenYpixel valueSets the distance of the window from the top of the screen. scrollbarsyes/noSpecifies if the Scroll Bars are visible. titlebaryes/noSpecifies if the Title Bar is visible. toolbaryes/noSpecifies if the toolbar is visible. widthpixel valueSets the width of the window. z-lockyes/noSpecifies that the window is not supposed to be located above other windows when it is made active. <html>     <script language="JavaScript">     <!--     function openWin(){       var myBars = 'directories=no,location=no,menubar=no,status=no';       myBars += ',titlebar=no,toolbar=no';       var myOptions = 'scrollbars=no,width=400,height=200,resizeable=no';       var myFeatures = myBars + ',' + myOptions;       var myReadme = 'This is a test.'       var newWin = open('', 'myDoc', myFeatures);       newWin.document.writeln('<form>');       newWin.document.writeln('<table>');       newWin.document.writeln('<tr valign=TOP><td>');       newWin.document.writeln('<textarea cols=45 rows=7 wrap=SOFT>');       newWin.document.writeln(myReadme + '</textarea>');       newWin.document.writeln('</td></tr>');       newWin.document.writeln('<tr><td>');       newWin.document.writeln('<input type=BUTTON value="Close"');       newWin.document.writeln(' onClick="window.close()">');       newWin.document.writeln('</td></tr>');       newWin.document.writeln('</table></form>');       newWin.document.close();       newWin.focus();     }     -->     </script>     <body>     <form>       <b>Click the following button to open a new window: </b>       <input type=BUTTON value="Open" onClick='openWin()'>     </form>     </body>     </html>