Maintain minimum width and height of browser window when resizing

Posted on 2010-01-08
Last Modified: 2012-06-27

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(){

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 JavaScript
Question by:teenashah
    LVL 40

    Expert Comment

    on the onresize event of the window you can check the screenX and screenY properties of the window.
    if it is lesser than certain value, invoke window.resizeTo(minwidth, minheight);

    Author Comment

    Hi gurvinder372,
     In my question onlly i am applying fixed height and width on resize event of window. It works some how in FF but not in IE8.
    LVL 40

    Expert Comment

    this code is working fine on my machine
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
                function resizeWindow()


    <BODY BGCOLOR="#FFFFFF" onload='resizeWindow()'>
    LVL 40

    Expert Comment


    Author Comment

    Hi gurvinder372;

    Thanks for quick response. You code perfectly works, when i tried on other's machine. So onlaod event of body browser resizes to given dimension. But when onresize is getting fired with resizeto function IE8 gives "Access denied" error. Is it because of Ie not allowing this methode to execurte?
    LVL 40

    Accepted Solution

    Yes, thats what is seems and the expert-exchange link i posted earlier seems to confirm that.
    However, i have noticed that on my machine on IE8
    1) when i click on the maximize button, this code works
    2) when i resize from left side, this code works
    3) when i resize from right side, this code does not works

    Author Closing Comment

    Yes, it seems to be right solution

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
    In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
    The viewer will learn how to dynamically set the form action using jQuery.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now