JavaScript Window open() method

The JavaScript Window open() method is used to open a new browser window or tab. It takes two arguments: the URL of the page to open, and an optional string of window options.

Here are some examples of how the open() method can be used in JavaScript code:

  1. To open a new window with a specific URL, you can use the following code:
window.open('https://www.example.com');
  1. To open a new window with a specific size and position, you can use the following code:
window.open('https://www.example.com', '', 'width=800,height=600,left=100,top=100');
  1. To open a new window in a specific frame or window, you can use the following code:
window.open('https://www.example.com', 'myFrame');
  1. To open a new window with specific window features, such as a toolbar or scrollbars, you can use the following code:
window.open('https://www.example.com', '', 'toolbar=1,scrollbars=1');

Overall, the open() method provides a convenient way to open new windows or tabs in a web browser, and allows you to customize the size, position, and features of the new window.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: