Created
October 25, 2016 23:21
-
-
Save qwertypants/55e979e1eb34c3c96a10dbfd670d5382 to your computer and use it in GitHub Desktop.
Popup window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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