SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    united states
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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. #2
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't resize a window using document.body.clientWidth/Height, you need to use window.resizeTo()...
    Code:
    function pageResize() {
      var windowWidth = document.body.clientWidth;
      var windowHeight = document.body.clientHeight;
    		
      if (windowWidth < 100) {
         window.resizeTo(100,windowHeight;
      }
      if (windowHeight < 100) {
         window.resizeTo(windowWidth,100);
      }
    }
    that should do the trick!

  3. #3
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may wish to note that, according to Goodman's "Dynamic HTML: The Definitive Reference", the modal dialog ". . . has no scriptable relationship with its opening window once the dialog window is opened." This means any scripts to modify the dialog must be internal to its contents. The dialog has specific dimensional parameters, dialogHeight, dialogWidth. Variables can be passed to the dialog at opening through the opening syntax.

    I assume you realize the modalDialog is IE-only.
    Last edited by JVLB; Jun 27, 2004 at 18:02.

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    united states
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My dialog window is a bit more complicated than that, and I was hoping you could help me modify the code so that the resizing will work.

    The dialog window is actually composed of 3 frames.
    This is the code of the dialog window that gets opened:
    Code:
    <html>
      <head>
        <title>dialog title</title>
      </head>
      <frameset rows="43,*, 29" frameborder="0" framespacing="0" border="0">
        <frame src="top.php" scrolling="no" noresize>
        <frame src="main.php">
        <frame src="bottom.php" scrolling="no" noresize>
      </frameset>
    </html>
    Now, I am not sure where to put the code for handling the dialog resizing.
    I tried to put it in main.php's body's onresize event handler, like so:
    Code:
    <!-- this is the content of main.php -->
     ...
      <body onresize="pageResize()">
     ...
    This is what the pageResize looks like:
    Code:
    function pageResize() {
      var windowWidth = document.body.clientWidth;
      var windowHeight = document.body.clientHeight;
    		
      if (windowWidth < 300) {
        window.resizeTo(300,windowHeight);
      }
      if (windowHeight < 300) {
        window.resizeTo(windowWidth, 300);
      }
    }
    I tried resizing the window, but then I am not sure which window should get resized. Should it be the main frame, or maybe it should be the outer parent frame...

    please help

  5. #5
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm guessing a bit here, since I tend to avoid IE-only stuff, but I think the properties you would be addressing would be top.dialogHeight and top.dialogWidth from any of the frames.


Bookmarks

Posting Permissions

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