Click to See Complete Forum and Search --> : centering pop-up for a beginner


random
02-25-2004, 06:44 PM
i realize this is a common question and there is a webpage here explaining how to do it. but i don't want to change all of my links to declare width and height. in other words how could adjust this function to open the pop-ups centered without touching my link coding?


<script language="JavaScript">
function mapshot(link)
{ window.open(link,'newmap','titlebar=no,width=700,height=525,scrollbars=no'); }
</script>

steelersfan88
02-25-2004, 06:54 PM
Change your function to:

<script language="JavaScript">

function mapshot(link) {
newWin = window.open(link,'newmap','titlebar=no,width=700,height=525,scrollbars=no');
var x = (screen.width - 700)/2
var y = (screen.height - 525)/2
newWin.moveTo(x,y)
}

</script>Of course, this will produce an error on pages off your server.

Of course, this is assuming you call the function somewhat like this:

<a href="myPage.htm" onclick="mapshot(this.href);return false;">myPage.htm</a>