Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @vangware/window-open-promise with all npm packages installed. Try it out:

var windowOpenPromise = require("@vangware/window-open-promise")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@vangware/window-open-promise v3.0.3

Promised Window.open

@vangware/window-open-promise logo

Build Status License NPM Version Open Issues Size

Promised Window.open.

Usage

📦 Node

import windowOpenPromise from "@vangware/window-open-promise";

windowOpenPromise({
    url: "https://example.com", // URL is not required, you can open a blank window
    features: { alwaysOnTop: true }
})
    .then(newWindow => {
        newWindow.console.log("This will log in the new window.");
        newWindow.addEventListener("beforeunload", _event => {
            console.log("This will log when the new window is closed.");
        });
    })
    .catch(_error => {
        console.error("This will log if the new window can't be opened.");
    });

🦕 Deno

import windowOpenPromise from "https://cdn.skypack.dev/@vangware/window-open-promise";

try {
    const newWindow = await windowOpenPromise({
        url: "https://example.com", // URL is not required, you can open a blank window
        features: { alwaysOnTop: true }
    })
    newWindow.console.log("This will log in the new window.");
    newWindow.addEventListener("beforeunload", _event => {
      console.log("This will log when the new window is closed.");
    });
} catch (_error) {
    console.error("This will log if the new window can't be opened.");
}
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free