Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    setting a minimum size for a modal dialog

    Hi people

    I am using window.showModalDialog() to open a modal dialog window.
    I would like to set a minimum size for the window (width & height).

    I set the following:
    Code:
    <body onresize="pageResize()">
    ...
    </body>
    In a javascript file I have:
    Code:
    function pageResize() {
      var windowWidth = document.body.clientWidth;
      var windowHeight = document.body.clientHeight;
    		
      if (windowWidth < 100) {
         document.body.clientWidth = 100;
      }
      if (windowHeight < 100) {
         document.body.clientHeight = 100;
      }
    }
    I get an error saying: "Object doesn't support this action" for line settings:
    Code:
    document.body.clientWidth = 100;
    Is there another way of doing that?

    thanks in advance

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Properties such as clientWidth are read-only.

    If I recall correctly, once opened, the width and height properties of an html dialog can only be modified from an html application.

    They can be set initially in the showModalDialog call, however.

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I solved the problem.
    Taken from the MSDN library (concerning the usage of resizeTo):
    This method does not work on dialog windows. In order to move or size a dialog window, manipulate the dialogHeight, dialogWidth, dialogTop, and dialogLeft properties.
    This is my final solution:
    Code:
    function pageResize() {
      var currentHeight = 0;
    
      // the frames are set one on top of the other - so I am calculating the total height
      for (i=0; i<parent.frames.length; i++) {
        currentHeight += parent.frames[i].document.body.clientHeight;
      }
      var currentWidth = parent.frames[0].document.body.clientWidth;
    			
      if (currentWidth < 300) {
        parent.dialogWidth = "300px";
      }
      if (currentHeight < 300) {
        parent.dialogHeight = "300px";
      }
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •