Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. /**
  2. * Opens a new browser window
  3. * @param {String} url The url of the window to open
  4. * @param {String} name The name of this window
  5. * @param {Number} width Window width
  6. * @param {Number} height Window height */
  7. const PopUpWindow = (url, name, width, height)=> {
  8. // Center the window
  9. let _width = width || 450,
  10. _height = height || 300,
  11. left = (screen.width / 2) - (_width / 2),
  12. right = (screen.height / 2) - (_height / 2);
  13. let options = [
  14. 'width=' + _width,
  15. 'height=' + _height,
  16. 'left=' + left,
  17. 'top=' + right,
  18. 'resizable=0',
  19. 'menubar=0',
  20. 'centerscreen=1',
  21. 'location=0',
  22. 'scrollbars=0',
  23. 'toolbar=0',
  24. 'status=0'
  25. ];
  26. const newwindow = window.open(url, name, options.join(','));
  27. if (window.focus) {
  28. newwindow.focus();
  29. }
  30. };
  31. export default PopUpWindow;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement