1.1.26 ā¢ Published 3 days ago
window-open-promise v1.1.26
šŖ 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-promise
Import 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.26
3 days ago
1.1.25
4 days ago
1.1.24
7 days ago
1.1.23
20 days ago
1.1.22
21 days ago
1.1.21
22 days ago
1.1.18
28 days ago
1.1.20
27 days ago
1.1.17
1 month ago
1.1.16
1 month ago
1.1.15
1 month ago
1.1.14
1 month ago
1.1.13
1 month ago
1.1.12
1 month ago
1.1.11
2 months ago
1.1.10
4 months ago
1.1.9
4 months ago
1.1.8
4 months ago
1.1.7
4 months ago
1.1.6
4 months ago
1.1.5
4 months ago
1.1.1
5 months ago
1.1.4
5 months ago
1.1.3
5 months ago
1.1.2
5 months ago
1.1.0
5 months ago
1.0.3
5 months ago
1.0.2
5 months ago
1.0.1
6 months ago
1.0.0
6 months ago