Forcing new windows to be a certain size and position
Im going to try and post this, and hopefully someone will be able to help. I really dont know what im doing wrong with my posts, and apologies if I am but no one seems to answer them.
I have a website with several links and when each new window opens I would like to be able to force not only the size of the Window but to center it too!?
Could someone offer some greatley appreciated advice!
Megan posted this at 13:12 — 7th September 2007.
She has: 11,421 posts
Joined: Jun 1999
Sorry you're not getting answers to your questions! I'll take a look and see if there are any I can help with.
Are you using target_blank of a javascript pop-up to open the window? To resize a new window you'll have to use JavaScript. Here is a tutorial:
http://www.pageresource.com/jscript/jwinopen.htm
You won't be able to centre the window - only position it from the top-left corner (that's explained at the bottom of that page).
Megan
Connect with us on Facebook!
mfdc posted this at 14:11 — 7th September 2007.
They have: 160 posts
Joined: Aug 2004
Bless you, thats delightful
Thanks
teammatt3 posted this at 01:02 — 8th September 2007.
He has: 2,102 posts
Joined: Sep 2003
Couldn't you get the size of the monitor using screen.width and screen.height and since you have the size of the browser window, you could do some math to figure out how far from the top and left would make the browser center? I haven't done it, but it might work. IE, Opera and Firefox probably have different opinions on what constitutes the browser window, so your centering might be a bit off.
Megan posted this at 13:52 — 10th September 2007.
She has: 11,421 posts
Joined: Jun 1999
Um, don't use pop-up windows? Almost always a bad idea but mfdc didn't ask about that Maybe he's got a good reason for it.
Oh, right you could do it that way. You'd also have to do some math to get what the x,y position of the top-left corenr of the window would be relative to the center of the screen. But who would go to that much trouble just to center a pop-up?
Megan
Connect with us on Facebook!
mfdc posted this at 14:08 — 10th September 2007.
They have: 160 posts
Joined: Aug 2004
The windows that open must have navigation via scrollbars hence regular windows would of been fine, pop ups a no no!
webwiz posted this at 16:52 — 8th September 2007.
He has: 629 posts
Joined: May 2007
I hesitate doing something like this, as I don't know how to do it unobtrusively.
Modern browsers allow you to stop JavaScript from resizing and moving windows. In addition, most pop-up blockers will not open a new window without permission. This adds a barrier to visitors that may well put them off. It also raises usability issues.
Anyone have a solution to these issues?
Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.