https://github.com/webdeveric/popup-window
Open popup windows
https://github.com/webdeveric/popup-window
popup-window
Last synced: 9 days ago
JSON representation
Open popup windows
- Host: GitHub
- URL: https://github.com/webdeveric/popup-window
- Owner: webdeveric
- Created: 2015-07-19T00:17:22.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-08-27T22:29:46.000Z (over 4 years ago)
- Last Synced: 2025-04-30T15:18:46.606Z (12 days ago)
- Topics: popup-window
- Language: JavaScript
- Size: 40 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Popup
[](https://nodei.co/npm/popup-window/)
## Example usage
```javascript
let win = new Popup(
'http://webdeveric.com/',
{
name: 'window name goes here', // Optional
width: 600,
height: 400
}
);win.opened( ( win ) => {
console.log('Popup has been opened');
}).blocked( ( win ) => {
console.log('Popup has been blocked');
}).closed( ( win ) => {
console.log('Popup has been closed');
});win.open();
```## Window features
The window will have these features by default.
You can pass in an object with some or all of these settings to the constructor, as shown above.
If the `width` or `height` is null, it will be calculated to be half the screen width/height.
If the `left` or `top` is null, it will be calculated so that the window is in the center of the screen.```javascript
{
width: null,
height: null,
left: null,
top: null,
menubar: 0,
toolbar: 0,
location: 1,
status: 1,
resizable: 1,
scrollbars: 1
}
```## Methods
- **open** - open the window.
- **close** - close the window.
- **opened** - accepts a callback - the callback is called when the window is opened.
- **closed** - accepts a callback - the callback is called when the window is closed.
- **blocked** - accepts a callback - the callback is called when the window is blocked from opening.The `opened`, `closed`, and `blocked` callbacks receive the `Popup` instance as the only argument.