Skip to content

Instantly share code, notes, and snippets.

@qwertypants
Created October 25, 2016 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qwertypants/55e979e1eb34c3c96a10dbfd670d5382 to your computer and use it in GitHub Desktop.
Save qwertypants/55e979e1eb34c3c96a10dbfd670d5382 to your computer and use it in GitHub Desktop.
Popup window
/**
* Opens a new browser window
* @param {String} url The url of the window to open
* @param {String} name The name of this window
* @param {Number} width Window width
* @param {Number} height Window height */
const PopUpWindow = (url, name, width, height)=> {
// Center the window
let _width = width || 450,
_height = height || 300,
left = (screen.width / 2) - (_width / 2),
right = (screen.height / 2) - (_height / 2);
let options = [
'width=' + _width,
'height=' + _height,
'left=' + left,
'top=' + right,
'resizable=0',
'menubar=0',
'centerscreen=1',
'location=0',
'scrollbars=0',
'toolbar=0',
'status=0'
];
const newwindow = window.open(url, name, options.join(','));
if (window.focus) {
newwindow.focus();
}
};
export default PopUpWindow;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment