Forum Moderators: open

Message Too Old, No Replies

Restricting the size of a browser window

Restrict window size on opening

         

mikejson

2:23 pm on Oct 7, 2003 (gmt 0)

10+ Year Member



I don't know how to do this, basically cause I've never done this before, I'll be searching the net and will be coming back here.

Basically I just want to know what are the different ways I can restrict the size of the window?


With the situation I'm in, I have limited access to the entire web page code. I can only do stuff after the body element has been called. Is there a way to restrict the access from there?(please don't ask why HAHA, long story)

korkus2000

2:33 pm on Oct 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Open the page in a new window. You really can't restrict the size of a window you didn't spawn.

mikejson

2:48 pm on Oct 7, 2003 (gmt 0)

10+ Year Member



hmm, so when someone clicks this link(it will spawn a new page, but I have no control over the link itself), I can't resize the browser at all?

Dayo_UK

2:52 pm on Oct 7, 2003 (gmt 0)



<a href="page.htm" onClick="popup = window.open('page.htm', 'PopupPage', 'height=200,width=500,scrollbars=yes,resizeable=no'); return false" target="_blank">

I think the above should work :) - you can play with the sizes, scrollbars, resizeable yes,no etc.

I think this is what you are after?

mikejson

3:40 pm on Oct 7, 2003 (gmt 0)

10+ Year Member



I don't really have control over the link itself though...

Its in an email, I could look at creating the email as an html file but... that's alot more work.

MonkeeSage

5:53 pm on Oct 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use the resizeTo() method (which takes two ints as params: width, height), but only if you have a window handle to use it on; and you can't really get a window handle unless you use the built-in variables for the page you are currently viewing (i.e. self or window), or if you open a new window and catch the handle it returns into a variable.

So you could resize the current window...

self.resizeTo(900, 600);

or open a new window and then resize it...

var win = window.open('http://somewhere.blah','','');
win.resizeTo(900, 600);

I'm not aware of any other way to dynamically change the size of the window.

Also, on Mozilla / Phoenix this method can be disabled and the window will not resize. They don't usually like to give that kind of control to the coder because it is very easy to be misused. A site could, in theory, open a new window, size it to 1 x 1, move it off the screen, then, e.g., submit votes for a site every 20 seconds; or could size the window to some gargantuan size like 500000 x 400000 to make it hard to close (the window controls are way off the screen), &c.

Jordan

mikejson

9:03 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



that makes sense, I guess I just have to see if I can get more control over the link/email to open the window how I want.

Thanks for the help guys/gals