Resize browser to specified pixel
I want resize browser window to 1000x700 pixel by de开发者_JAVA技巧fault 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
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.
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?
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:
精彩评论