Make a new window : Window « Window Browser « JavaScript DHTML






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>


           
         
    
  








Related examples in the same category

1.Communicating with a New Window
2.Using the window.close() Method to Close a Browser Window
3.Popup window animation (fly across screen)
4.Hyper link to close window
5.Close window and open document in new window
6.Open a new link from a button
7.Open a new window and control its appearance
8.Open multiple windows at one click
9.Resize a window
10.Resize a window to a specified size
11.Scroll the window
12.New Window Laboratory
13.Creating an always Raised Window
14.Window Property Picker
15.Window Resize, motion, maximize
16.Creating a New Window
17.Window Resize Methods
18.Window focus and blur()
19.Opening and Closing Windows
20.Opening a New Window
21. A Main Window Document
22.References to Window Objects
23.Simple Notification: Display Window Info
24.Properties and Methods of the Window Object
25.Capturing Click Events in the Window
26.Contents of a Main Window Document That Generates a Second Window
27.Setting Window Height and Width(Firefox)
28. Checking Before Closing a Window
29.Open a window and center it
30.Maximize Window for different browser
31.Scroll Window
32.Preventing a Page from Scrolling
33.Open a new window setting height, width and position
34.Move a window
35.To hide JavaScript errors from the user
36.Using document.write() on the Current Window
37.Using document.write() on Another Window