Hi,
I'm using a javascript so when someone clicks on a link a new javascript window will pop up. The problem is that the window always pops up at the right.
How can i make it pop up in the middle?
Thanks
| SitePoint Sponsor |





Hi,
I'm using a javascript so when someone clicks on a link a new javascript window will pop up. The problem is that the window always pops up at the right.
How can i make it pop up in the middle?
Thanks

Try this little script
http://www.tripod.lycos.co.uk/webmaster/tips/987514804/



or try here:
http://www.codeproject.com/jscript/popup.asp
click on link at top to download .js file
Compwizard
"There are 10 kinds of people in this world -- those who know binary, and those who don't."





You can always use the moveTo method to move
the window once it's opened.
Flawless
---=| If you're going to buy a pet - get a Shetland Giraffe |=---




I didn't check the links the other guys posted, so this might be the same as one of theirs.
Put this in the <Head> statement:
<script language="javascript" type="text/javascript">
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}
</script>
Then use this kind of thing as the link:
<a href="mypage.htm" onclick="NewWindow(this.href,'name','400','400','no');return false">





Thanks all for the replies.
Community Guidelines | Community FAQ
"He that is kind is free, though he is a slave;
he that is evil is a slave, though he be a king." - St. Augustine
Bookmarks