Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

How to centralise a javascript popup

Thread Tools
 
Search this Thread
 
Old 09 May 2003, 09:24 AM
  #1  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

I have the following code for a javascript popup

<script>
function openpopup(){
var popurl="password.htm"
winpops=window.open(popurl,"","width=256,height=12 1,left=100,top=50")
}
</script>

How do I set the left and top settings so it will centralise the popup on in any resolution??

Cheers.
Old 09 May 2003, 09:34 AM
  #2  
SJ_Skyline
Scooby Senior
 
SJ_Skyline's Avatar
 
Join Date: Apr 2002
Location: Limbo
Posts: 21,922
Likes: 0
Received 1 Like on 1 Post
Thumbs up

This seems to work in IE6 - change the var values to change your window size.


function openpopup()
{
var popurl="password.htm";
var screen_height = screen.height;
var screen_width = screen.width;
var window_height = 121;
var window_width = 256;
var offset_x = ((screen_width - window_width) / 2);
var offset_y = ((screen_height - window_height) / 2);
winpops = window.open(popurl,"","width=" + window_width + ",height=" + window_height + ",left=" + offset_x + ",top=" + offset_y);
}




Rich
Old 09 May 2003, 11:39 AM
  #3  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

Thanks. My site is 100% IE so cross browser compatability isn't a problem
Old 09 May 2003, 11:42 AM
  #4  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

Works a treat
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
ptholt
Computer & Technology Related
36
18 September 2002 04:17 PM
WRX.
Computer & Technology Related
9
02 September 2002 07:19 PM
Jer
Computer & Technology Related
3
08 January 2002 06:37 PM
Markus
Computer & Technology Related
5
04 January 2002 04:19 PM



Quick Reply: How to centralise a javascript popup



All times are GMT +1. The time now is 11:10 PM.