Click to See Complete Forum and Search --> : Centering a Pop up!


steiner_99
02-24-2003, 12:42 PM
does anyone know the javascript to add to
center my opo up window???

http://www.nicothekitty.com
Thanks guys

pyro
02-24-2003, 12:59 PM
Take a look at this script: http://javascript.internet.com/navigation/centered-popup.html

Charles
02-24-2003, 01:41 PM
Like most all scripts from that site, that one has a few problems. Use instead:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Window Example</title>
<script type="text/javascript">
<!--
function newWin(url, height, width) {
if (navigator.appName == 'Opera') return true;
// the following will give unacceptable results in Opera running in "Multiple Document Interface" mode
var y = 0;
var x = Math.floor((screen.width - width) / 2);
var param = 'height=' + height;
param += ',width=' + width;
param += ',height=' + height;
param += ',screenX=' + x;
param += ',left=' + x;
param += ',screenY=' + y;
param += ',top=', + y;
window.open(url, 'child', param);
return false;
}
// -->
</script>
<p><a href="http://www.w3.org/" onclick="return newWin(this.href, 400, 300)">W3C</a></p>