Open a new window

This script shows how to open a new page inside a new window rather than the existing window. You can also remove all the buttons and toolbars that exist in the standard browser window so that the entire new window is filled with only your content. You could either open an existing page or you could create dynamic content inside the new window.


<SCRIPT LANGUAGE = "JavaScript">
<!--

function open_new_window() {
 dlg = window.open ("newpage.html" ,"NewWindowName" , "width=400,height=400,
toolbar=no,location=no,directories=no,
status=no,menubar=no,scrollbars=no,resizable=no")  
}

function open_new_window2() {

 dlg = window.open ("","NewWindowName2","width=400,height=400,toolbar=no,location=no,
directories=no,status=no,menubar=no,scrollbars=no,resizable=no")
dlg.document.write ("<BODY bgColor='#FFFFFF'>")
dlg.document.write ("<CENTER>This is text that has been added on the fly using Javascript.</CENTER>")
dlg.document.write ("</BODY>")  
}
-->
</SCRIPT>

<BODY>
<A onClick='open_new_window()' >Click anywhere on this text to open the file newpage.html in a new window</a><br>

Or click on the button below to open a dynamically generated html page<br>

<FORM>
<INPUT type="button" value="New Window" onClick ='open_new_window2()' >
</FORM>
</BODY>

You might also like...

Comments

Kiran Pai

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila” - Mitch Ratcliffe