0

This is driving me nuts. I'm a copy/paste kind of guy(!) so please be gentle.

Previously, I've used this solution (Stack link) to make a centered popup which has worked perfectly (on in internal CMS site) but for some reason, I can't get it to work on a new site (not on the CMS).

I know I'm missing something but I just can't see what it is!!

HTML:

<a class="twitter" href="https://twitter.com" onclick="PopupCenter(this.href,'myWindow','550','550');return false" target="_blank">Center Popup</a>

Javascript:

function PopupCenter(url, title, w, h) {  
    // Fixes dual-screen position                         Most browsers      Firefox  
    var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;  
    var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;  

    width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;  
    height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;  

    var left = ((width / 2) - (w / 2)) + dualScreenLeft;  
    var top = ((height / 2) - (h / 2)) + dualScreenTop;  
    var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);  

    // Puts focus on the newWindow  
    if (window.focus) {  
        newWindow.focus();  
    }  
}

JSFiddle

Community
  • 1
  • 1
Kungfauxn00b
  • 567
  • 2
  • 5
  • 14

1 Answers1

0
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Pop Up</title>
        <script src="popup.js"></script>
    </head>

    <body>
        <a class="twitter" href="https://twitter.com" onclick="PopupCenter(this.href,'myWindow','550','550');return false" target="_blank">Center Popup</a>
    </body>
</html>
Samer Ayoub
  • 981
  • 9
  • 10