Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi guys! I am using this code to d

Status
Not open for further replies.

dirtystim

Technical User
Jul 4, 2001
26
GB
Hi guys!
I am using this code to do a pop up window, but what code do I have to put in so it positions itself centre, centre?
I really want to use the same script, but just to MODIFY it.
Can NE1 help?
I want to Modify this one as the dark recesses of my neanderthal brain seeks knowledge! (But it takes a (stone) age for me to understand anything!)


please help a lesser being! just think about that good karma you'd be stockpiling :)

Thanks loads!

dirtystim


here's the code
===========pop up code===========
<html>
<head>
<title>Untitled</title>
<script language =&quot;javascript&quot;>
win=&quot;&quot;;
function pop_up(){
win = window.open(&quot; &quot;dep&quot;, &quot;height=100,width=200&quot;, hotkeys=&quot;no&quot;);
}
function closeDep() {
if (win==&quot;undefined&quot;){}else{
if (win.open) win.close();
}
}
</script>
</head>
<body onUnload=&quot;closeDep();&quot;>
<a href=&quot;#&quot; onclick=&quot;pop_up();&quot;>Yahoo</a>
<br><br><br>
<a href=&quot;#&quot; onClick=&quot;closeDep();&quot;>Close the window</a>
</body>
</html>
 
Modify the script to the following:
win=&quot;&quot;;
function pop_up(){
//To get the variables for centering
var centerx,centery,tempy,tempx;
tempx=window.screen.availHeight/2;
centerx=tempx-50;
tempy=window.screen.availWidth/2;
centery=tempy-100;
win = window.open(&quot; &quot;dep&quot;, &quot;height=100,width=200&quot;, hotkeys=&quot;no&quot;);
//Move the window to the center
win.moveTo(centerx,centery);
}
function closeDep() {
if (win!=&quot;undefined&quot;){
if (win.open) win.close();
}
}

I haven't tested this script but it might work.
At least get you on the right track. :)
Hope this was helpful
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top