user1034912
user1034912

Reputation: 2257

How to create a Web Popup Window without referring to a new html file?

How do you create a Web Popup Window without referring to a new html file?

All the codes I've found requires to refer to a new file where the popup document sits.

Thanks for you help!

Upvotes: 0

Views: 677

Answers (1)

Rob W
Rob W

Reputation: 348992

Pass about:blank as the target:

window.open('about:blank', 'name_of_window', 'popup');

If you want to manually construct a document:

var popup = window.open('about:blank', 'name_of_window', 'popup');
if (!popup) { // popup is `null` if the window is blocked
    // Otherwise, popup is the Window object of the popup
    popup.document.write('Test');
}

Upvotes: 1

Related Questions