Create a new window javascript
Here is an example of how to create a new window in JavaScript:
// Create a new window
var newWindow = window.open("https://www.example.com", "_blank", "width=400,height=300");
// Set the title of the new window
newWindow.document.title = "New Window";
// Set the content of the new window
newWindow.document.write("<h1>Welcome to the new window!</h1>");
This code creates a new window with the URL https://www.example.com
, sets the title of the window to "New Window", and sets the content of the window to an <h1>
element with the text "Welcome to the new window!".
You can also specify additional options when creating the new window, such as:
toolbar
: whether to display the toolbar (default istrue
)menubar
: whether to display the menu bar (default istrue
)statusbar
: whether to display the status bar (default istrue
)scrollbars
: whether to display scrollbars (default istrue
)resizable
: whether the window can be resized (default istrue
)directories
: whether to display the directory buttons (default isfalse
)location
: whether to display the location bar (default istrue
)titlebar
: whether to display the title bar (default istrue
)
For example:
var newWindow = window.open("https://www.example.com", "_blank", "width=400,height=300,toolbar=false,menubar=false,statusbar=false");
This code creates a new window with the URL https://www.example.com
, sets the width and height to 400x300, and disables the toolbar, menu bar, and status bar.
Note that the window.open()
method returns a reference to the new window, which you can use to access its properties and methods.