In IE it uses the showModelessDialog method which places the new window in the center of the user's screen. In all others it uses the open method, for which you may (using the modified script below) specify the top and left coordinates:
Code:
<script>
//Modeless window script- By DynamicDrive.com
//for full source code and terms of use
//visit http://www.dynamicdrive.com
function modelesswin(url,mwidth,mheight,mtop,mleft){
if (window.showModelessDialog){ //if ie5
window.showModelessDialog(url,"","help:0;resizable:0;dialogWidth:"+mwidth+"px;dialogHeight:"+mheight+"px");
}
else
window.open(url,"","top="+mtop+",left="+mleft+",width="+mwidth+"px,height="+mheight+"px,resizable=1,scrollbars=0");
}
//To load via link, use something like below:
//<a href="ext.htm" onclick="modelesswin(this.href,300,300,250,400);return false;">ext</a>
</script>
They are, for the example link 250 and 400 respectively, as highlighted above.
If you want them all to be centered, that can be arranged, or if you want IE to use the open method too so that it will be positioned as set in the link code, that can be done too.
Be aware that if you specify numbers for top and left, theses will be in relation to the user's screen. On larger screens it will be proportionately closer to the top and left, on smaller ones, farther. So much so on smaller screens that it might be too far to the right or bottom to be fully seen, or seen at all.
For that kind of control, use:
http://www.dynamicdrive.com/dynamicindex8/popwin.htm
One odd man out for this in the browser world is Opera. It sees top and left differently than all others and dependent upon factors that cannot be read from it, so cannot really be relied upon to position a new window as desired. Often it still renders it 'in the neighborhood' though usually lower.
Considering all that, it might be a good idea not to position it (use the original code). At least that way the browser will show the whole thing if at all possible.
Bookmarks