views:

137

answers:

4

Hi,

I want resize browser window to 1000x700 pixel by default on load of html page. Also whenever you resize window the minimum dimension 1000x700 should be maintained. I tried

window.onresize = function(){
    window.resizeTo(1000,700);
};

but in IE8 its not working giving error "Access denied", however in FF its work fine.

Please guide me with some alternate solution that can be handled using JS

+8  A: 

It's disabled by default in IE. And Chrome. And Opera. It can be disabled in Firefox too. There is a very good reason for this, namely that it's absolutely obnoxious. Everyone hates having their browser tampered with.

You can't stop the window being resized either, thank goodness, short of trapping onresize and calling resizeTo in response, for the last few browsers where that will do anything.

If you want a window that's a specific size, you can try window.open​ing a new one in that size. You can even ask for it to be unresizable. Although, again, many browsers will simply ignore your unreasonable user-hostile request.

bobince
Hi,The requirement is to stop window to be resized to the minimum dimension i.e. 1000X700 px. So i am trying to resize window again if its dimension falls below 1000X700 px. And window.open 'll open new window, requirement is not that.
Asif
See if you can convince your client not to have such a requirement. bobince has posted valid points for you to use as reasoning.
Salman A
Yes i also understand, but to convince client i need some concrete reason that "This is not possible using script", so can you drop this idea?. So kindly give me advice, whether it is possible or not using Jvascript.
Asif
It is not possible with JavaScript in the majority of browsers.
bobince
+1  A: 

While it may work in some browsers, it may not work in others, depending on browser make, version and user preferences. For example, in FireFox you have:

Firefox JavaScript settings

Salman A
informative but not solution .. anyway +1 for sharing .. :)
infant programmer
+2  A: 

There is no reliable solution for all browsers. You can capture the onresize event, and fire a resizeTo, but as you know this doesn't work in all browsers. If you opened the ORIGINAL window, you can set it to a fixed size. I've had to do this for content in the past that has a specified viewable size. Also, what happens when viewing on my 1024x600 netbook?

Tracker1
A: 

I realize that there is some obnoxiousness to this, but if I have a web based application where I want to control the minimum size of the browser so that the user never has to scroll there is a valid reason for needing the ability to do this.

Bleu