Javascript to create a nice popup window from a hyperlink

NOTE on 8/14/2015.   This code is compatible with recent Internet Explorer versions, but not if you have a space in the name of the "title" you feed the function.  It will not work in IE if you have a space.



<script language="javascript">

function popupwindow(url, title, w, h) {
    wLeft = window.screenLeft ? window.screenLeft : window.screenX;
    wTop = window.screenTop ? window.screenTop : window.screenY;

    var left = wLeft + (window.innerWidth / 2) - (w / 2);
    var top = wTop + (window.innerHeight / 2) - (h / 2);
    return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}

</script>




<p>&nbsp;&nbsp;&nbsp;View my resume:&nbsp;&nbsp;&nbsp;<a 
href="http://www.devinjohnson.com/testresume.asp" onclick="popupwindow
(this.href,'myWindow',800,400); return false">Click here</a></p>


Comments