1.1.32 ⢠Published 1 year ago
window-open-promise v1.1.32
šŖ Promised Window.open();.
Usage
š¦ Node
Install window-open-promise as a dependency:
pnpm add window-open-promise
# or
npm install window-open-promise
# or
yarn add window-open-promiseImport it and use it:
import { windowOpenPromise } from "window-open-promise";
const windowOpen = windowOpenPromise(globalThis);
windowOpen({
url: "https://example.com", // URL is not required, you can open a blank window
top: 10,
left: 10,
})
.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 window-open-promise using the npm: prefix, and use it directly:
import { windowOpenPromise } from "npm:window-open-promise";
const windowOpen = windowOpenPromise(globalThis);
try {
const newWindow = await windowOpen({
url: "https://example.com", // URL is not required, you can open a blank window
top: 10,
left: 10,
});
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.");
}š Browser
Import window-open-promise using esm.sh, and use it directly:
<script type="module">
import { windowOpenPromise } from "https://esm.sh/window-open-promise";
const windowOpen = windowOpenPromise(globalThis);
try {
const newWindow = await windowOpen({
url: "https://example.com", // URL is not required, you can open a blank window
top: 10,
left: 10,
});
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.");
}
</script>Useful links
- š Documentation: TypeDoc generated documentation.
- ā³ Changelog: List of changes between versions.
- ā Tests Coverage: Coveralls page with tests coverage.
1.1.29
1 year ago
1.1.28
1 year ago
1.1.30
1 year ago
1.1.32
1 year ago
1.1.31
1 year ago
1.1.26
1 year ago
1.1.25
1 year ago
1.1.24
1 year ago
1.1.23
2 years ago
1.1.22
2 years ago
1.1.21
2 years ago
1.1.18
2 years ago
1.1.20
2 years ago
1.1.17
2 years ago
1.1.16
2 years ago
1.1.15
2 years ago
1.1.14
2 years ago
1.1.13
2 years ago
1.1.12
2 years ago
1.1.11
2 years ago
1.1.10
2 years ago
1.1.9
2 years ago
1.1.8
2 years ago
1.1.7
2 years ago
1.1.6
2 years ago
1.1.5
2 years ago
1.1.1
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.0
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago