Object in modal dialog (showModalDialog) don't honor 100% width in ie8. Workaround?

1.1k views Asked by At

Believe it or not the 100% width feature does not seem to work correctly in a modal dialog in ie8.

Check out this simple sample code.

var retVal = window.showModalDialog(URL,window.self, "dialogWidth=600px;dialogHeight=305px;scroll=yes;status=yes;caption=yes;titlebar=yes;menubar=yes;toolbar=yes;help=yes;resizable=yes;center=yes;");


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
    <head>
    </head>
    <body>
        <div id="temp" style="width: 100%; height: 500px; border:1px solid red;">
        </div>
    </body>
</html>

Run this code and then resize the popup window. Notice that the red div remains the original size, not at 100%. I noticed ff has the correct behavior.

Is there are a wordaround?

Grae

1

There are 1 answers

2
blindfold On

you need to handle the resize event, otherwise the width of the dialog will not change.

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.resize.aspx

I use jQuery to do the event handling because the cross browser supprt...