Mega Code Archive

 
Categories / JavaScript DHTML / Window Browser
 

Make a new window

<html> <head> <title>A New Window</title> <script language="JavaScript" type="text/javascript"> var newWindow; function makeNewWindow() {     if (!newWindow || newWindow.closed) {         newWindow = window.open("","sub","status,height=200,width=300");         if (!newWindow.opener) {             newWindow.opener = window;         }         setTimeout("writeToWindow()", 500);     } else if (newWindow.focus) {         newWindow.focus();     } } function writeToWindow() {     var newContent = "<html><head><title>Sub Window</title></head>";     newContent += "<body><h1>This is a new window.</h1>";     newContent += "</body></html>";     newWindow.document.write(newContent);     newWindow.document.close(); // close layout stream } </script> </head> <body> <form> <input type="button" value="Create New Window"  onclick="makeNewWindow();"> </form> </body> </html>