Guest User

Untitled

a guest
Oct 17th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. function PopupCenter(url, title, w, h) {
  2. // Fixes dual-screen position Most browsers Firefox
  3. var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX;
  4. var dualScreenTop = window.screenTop != undefined ? window.screenTop : window.screenY;
  5.  
  6. var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
  7. var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
  8.  
  9. var left = ((width / 2) - (w / 2)) + dualScreenLeft;
  10. var top = ((height / 2) - (h / 2)) + dualScreenTop;
  11. var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
  12.  
  13. // Puts focus on the newWindow
  14. if (window.focus) {
  15. newWindow.focus();
  16. }
Add Comment
Please, Sign In to add comment