Here’s my JavaScript code.
<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname) {
if (! window.focus) return true;
var href;
if (typeof mylink == 'string')
href=mylink;
else
href = mylink.href;
window.open(href, windowname, 'width=500,height=500,scrollbars=yes');
return false;
}
//-->
</SCRIPT>
Using just the code above, the pop up appears exactly how i want it, but it appears snuggly tucked into the upper left hand corner. I want the pop up to appear centered.
I’ve tried several suggestions on this website (such as:
var left = screen.width / 2 - w / 2;
var top = screen.height / 2 - h / 2;
but plugging anything else into the code i already have makes the pop up open in a new tab of the same browser (ignoring the pop up function).
That’s the problem I came here to have solved.
Additionally, I’d like to fade the background to draw the reader’s focus to the pop up. Is there a javascript snippet that i can toss in that will do so?
Try this:
Fading of the background window can be done by creating overlay.
With following css style: