Forum Moderators: open

Message Too Old, No Replies

Window resizing, and size locking.

What?

         

mrDaf

11:38 am on Jun 18, 2004 (gmt 0)

10+ Year Member



Ok, it's relatively simple, I have a page that needs to be a certain size horizontally, but I also need it to stay that size. The vertical is not important, but would be better if that could still be resized, for different res's etc.

I've used this code in the <head> section:

<script type="text/javascript" language="javascript">
window.resizeTo(695,700);
</script>

This resizes the page every time it loads. Is there similar code which I can use to lock the size of the page on the x-axis but let the y-axis be resized what ever?

All help appreciated.

Cheers.

j4mes

12:02 pm on Jun 18, 2004 (gmt 0)

10+ Year Member



Hi mrDaf (and welcome to WebmasterWorld!)

It's possible to lock both the x- and y-sizes when opening a new window:


<script language="JavaScript">
window.open('WindowURL','WindowName','[b]resizable=no[/b],width=695,height=700');
</script>

But I'm not sure if it's possible to fix just one direction.

I'd be careful - people don't like being told how big their windows should be, and may be annoyed when they lose control over it.

Perhaps you could give us a bit more information about what this is for?

James.

Leosghost

12:08 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This is usually a pron site "trick" along with an exploit in IE which then locks up the "close window" and F4.....not polite ..

mrDaf

1:40 pm on Jun 18, 2004 (gmt 0)

10+ Year Member



Well, it's for this:
<snip>

The link will only active for 30 minutes so be quick.

I don't want to open it new, I just want it to 'do' it.

Nah it's not a trick site, it's just ugly with all the white space. I'll do something with it sooner or later, but I'm too busy coding at the present moment.

Cheers for the welcome.

[edited by: engine at 2:54 pm (utc) on June 18, 2004]
[edit reason] No urls, thanks. See TOS [webmasterworld.com] [/edit]

Bernard Marx

1:58 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I really don't want people doing that to my window. If you insist though...

window.onresize = function()
{
this.resizeTo(695,getWinHeight())
}

This doesn't lock the window's width, but will make it snap back if resized. This is likely to make it even more irritating.

There is something I've left out:

getWinHeight()
. If you want to leave the height alone, you need to know what it is to start with. The window outer dimension properties are browser-specific, and I'm not sure what they all are. You'd have to do the function yourself.

bsilby

5:40 am on Jun 21, 2004 (gmt 0)



Hi,
Be careful with resizing windows. Winxp SP2 has put a lot of restrictions on script initiated changes to windows.

Brent.