JavaScript Open Window

A picture of a new small window compared to a bigger window to signify JavaScript Open Window

Create And Open Window In JavaScript

A new window can be opened in a new web browser window or tab.

Multiple windows can be opened and reused assuming that JavaScript is not disabled.

JavaScript open() method can take optional parameters for the name, URL and window dimensions.

Common Syntax Of Open Window In JavaScript

Glossary:

URL

Page to open.

Name

Target attribute or name of window.

Specs

Comm-separated list of items such as dimensions, location and scrollbars.

Common Methods For Open Window

Ojamboshop.com Learning JavaScript Open Window
Name Description Example
open() Create a new browser window. window.open();
open(url) The URL path to be opened. window.open(“https://ojamboshop.com”);
open(url, target) The target attribute such as new window or tab. window.open(“https://ojamboshop.com”, “_self”);
open(url, target) The target attribute such as new window or tab. window.open(“https://ojamboshop.com”, “_blank”);
open(url, target, specs) Comma-separated list of window features. window.open(“”, “Test”, “width=200,height=100”);
Name Description Example

JavaScript Open Window Snippet

// OjamboShop.com Learning JavaScript Open Window Tutorial

// Open Window
let newWindow = window.open("", null, "height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");  

// New Window Content
let p = newWindow.document.createElement("p");
let n = newWindow.document.createTextNode("Be sure to check out ");
p.id = 'content';
p.className = 'note';
p.appendChild(n);
newWindow.document.body.appendChild(p);
let link = newWindow.document.createElement("a");
link.setAttribute('href', 'https://ojamboshop.com');
link.appendChild(document.createTextNode('OjamboShop.com'));
p.appendChild(link);
let span = newWindow.document.createElement("span");
span.innerHTML = ` for the courses and to leave a donation click <a href="https://ojambo.com/donate">here<a>`;
p.appendChild(span);

JavaScript Open Window Code
OjamboShop.com Web IDE JavaScript Open Window Code

JavaScript Open Window Result
OjamboShop.com Web IDE Displaying JavaScript Open Window Result


Usage

You can use any IDE or text editor and the web browser to compile and execute JavaScript code. For this tutorial, the OjamboShop.com Learning JavaScript Course Web IDE can used to input and compile JavaScript code for the open window.

Open Source

JavaScript follows the ECMAScript standard and is licensed under the W3C Software License by web browser vendors and runtime environment vendors. This allows commercial use, modification, distribution, and allows making derivatives proprietary.

Live Stream

Every Friday, you can join a live stream and ask questions. Check Ojambo.com for details and instructions.

Learn Programming Courses:

Get the Learning JavaScript Course for your web browser on any device.

OjamboShop.com Learning JavaScript Course
OjamboShop.com Learning JavaScript Interactive Online Course

Learn Programming Books:

Learning Javascript Book is available as Learning JavaScript Paperback or Learning JavaScript Ebook.

OjamboShop.com Learning JavaScript Book Announcement
OjamboShop.com Learning JavaScript Ebook And Paperback Announcement

Conclusion:

JavaScript makes it easy to create content for new windows. New windows can be opened in the same window, as a new window or new tab.

If you enjoy this article, consider supporting me by purchasing one of my OjamboShop.com Online Programming Courses or publications at Edward Ojambo Programming Books

References:

Leave a Reply

Your email address will not be published. Required fields are marked *