I came across an interesting problem the other day. I was developing a way to have error dialog for our web application regardless of the web browser. I did not want to use the JavaScript alert message box. I could not use the IE Modal dialog. So I decided to display the error message in a DIV tag that would be centered on the screen and only made visible when there was an error. Then I thought, wouldn’t it be cool to be able to move the error dialog around the screen, in case it was covering up the form element that had a problem. I found dom-drag.js to be quite cool and
very helpful.
To make the DIV tag overlay the existing page, I needed to set the Z-index of the DIV at a higher level then anything else on the page. I soon found that no matter how hard you tried, all DropDownList boxes and List boxes would show through the error dialog.
After some research, I soon found that this is an issue with Internet Explorer and wasn’t much I could do about it. It is because DropDownList boxes and List boxes are considered a windowed component in the browser and regardless the z-index you assign these components or the DIV that contains them, they will always float to the top. This issue is resolved in IE7, but the idea of making all customers upgrade to IE7 was not acceptable.
An iFrame is also
windowed component. If I could put that iFrame in a DIV or TABLE that the visibility can be turned on or off, that would fix the problem of the other windowed components (drop down list and list box). I tried a DIV, but could not set the height to something specific so I could center the error dialog could be centered. I used the TABLE and could specify the height and it worked quite nice.
It wasn’t till later that I realized that everything under the TABLE, with no background, was not access-able. So once the error dialog window is made visible, the rest of the form elements can not be acted upon until you clear the error dialog.
To clear the error dialog, I needed to call a JavaScript function on the parent page to set the visibility of the TABLE equal to none. With out trying, I created my own modal dialog. Cool!
UPDATE:![]()
Not used to this blogging stuff, so let me clarify.
Outside the FORM tag I set a Table to be width=100% and height=560 (or something big enough to cover what you need to, then centered in that table (one row with one cell) I placed an IFRAME that I will pass my error message to and then display. The page shown in the IFRAME will cover all form elements on the page behind it. All form elements not covered by the IFRAME, but covered by the Err_Table are unclick-able with exception to the DropDownList and ListBox. If need be, you could alwasys disable those controls prior to making the Err_Table viewable.
</div>
</form>
<table id=”Err_Table” style=”display: none;”><tr><td width=”100%” height=“100%”>
<iframe id=”Err_Message_Frame” src=”" frameborder=”no”
scrolling=”no” marginheight=”0px” marginwidth=”0″></iframe>
</td></tr></table>
Style:
#Err_Table
{ position: absolute;
top:0px;
width: 100%;
height: 560px;
background-color: Transparent;
border: solid 0px red;
vertical-align: middle;
text-align: center;
z-index: 100;
}
#Err_Message_Frame
{
width: 360px;
height: 300px;
background-color: white;
border: solid 0px black;
margin: 0px;
padding: 0px;
}

12 comments
Comments feed for this article
November 15, 2006 at 1:02 pm
Anand
Hey Jim,
Thats a cool one…might start using for my apps. as well.
Thanks!
Anand
December 21, 2006 at 12:20 pm
Marc
Hi,
this looks like _exactly_ what I’ve been looking for, but I can’t make it behave like you say.
I created a little table on my page, and in the table cell, I’ve put an iframe with another page loaded in it. I’m able to drag it around and its layered over everything else, but how are you able to block interaction with things on the page that are not directly under the table/iframe?
For instance, in the sample image you posted, the error dialog is on the right… can you click those radio buttons on the left? If not, how did you accomplish that?
Thanks for your help.
Marc
December 21, 2006 at 1:25 pm
jrblack10
Marc,
I have revised or Updated my original post ( due to the fact I can not post code easily here ). Please review the original post.
February 16, 2007 at 8:35 am
Pavan
Hi Jim,
U have done a fabulous job. I am able to use it the way u have written.
But i have a different requirement where the the foating div is transparent. In such case all the items under it are visible except the list boxes.
Do u have any solution for this.
March 21, 2007 at 12:06 pm
Me
Hey,
Thanks for the solution. Internet Exploder sucks like hard. The programmers and managers of M$ really don’t know how to manage projects and code good software.
This hack works, but it’s really obvious that IE is just a piece of crap.
July 24, 2007 at 5:42 pm
adolfo
that thing mozilla sucks, it makes me go crazy every time I use it, I just love internet explorer because is the best browser of all. now with IE 7 this problem is solved. IE7 is better than that thing firefox by far. even fckeditor doesn’t work ion FF, and it does it perfectly in IE
July 25, 2007 at 8:47 am
jrblack10
adolfo, I don’t believe you know what you are talking about, nor what we are talking about. So stop spewing chunks all over and making a mess. Thank you for your comment.
November 1, 2007 at 2:20 am
sravanthi
What are the advantages and disadvantages in IE7
March 15, 2008 at 10:18 am
Sharan
Hii Jim
Can u give me the full code for the above example plzzz it will help me in my code
March 15, 2008 at 10:22 am
Sharan
actually i have different solution i m working in a code in that parent window opens a child window and till the child window is opened parent window should be disabled, i m using window.showModalDialog() but its working only in IE6 and not in Mozilla FF,what 2 do help me,and i dnt want to make my own modal dialog box
March 18, 2008 at 10:49 am
jrblack10
Sharan,
Sorry but I have not looked at this code in some time now… besides I have replaced this kind of functionality with AJAX server controls from the server control tool kit.
Best of luck.
March 28, 2009 at 10:15 pm
Albin
Some interesting examples are available on
http://www.javascripttoolbox.com/lib/popup/example.php