You are developing a web application that requires the user to take an action before doing anything else on the web page. Eg.,
- Click to keep session from being timed out.
- Confirm changes on the web page.
- Rate a product displayed on the web page.
- Accept clauses that pertain to certain actions on the web page.
- Forced reading of administrative messages.
What do you do? The only modal dialog options supported by the html standard today are alert, confirm and prompt. An alert dialog box displays a message with an “OK” button, Confirm displays a message/question with “OK” and “Cancel” buttons. Prompt displays a message with an input box for taking user input. The look and feel of these built-in dialog boxes is controlled by the browser. You cannot embed all the html tags/styles within these dialog boxes to make it look a part of your application.
There are a few workarounds available that are not part of the standard today. One of the popular ones is using a set of div tags containing a semi-transparent png image file that covers the entire web page. The modal dialog is then presented on top of this div. Just do a google search for “modal dialog box” . One of the sites that i found useful was http://javascript.about.com/library/blmodald1.htm . Another one exists here http://www.eggheadcafe.com/articles/javascript_modal_dialog.asp
If you are developing an application only for the Internet Explorer web browser (does anyone do that anymore?), you could make use of window.showModalDialog(url) which is IE-specific. It displays the content of a web page as a new modal window on top of the current web page.
In my personal opinion, its high time that the html standard came up with a consistent way to display modal dialog boxes so that the poor web developer does not have to come up with workarounds. This will save a lot of time and redundant scripting.
Hi Amar,
Yes, the web standards are not catching up so fast. HTML 5 is a work in progress. Not sure whether they are checking this Modal Dialog issue. basically this is JavaScript problem and ECMA should do something about it. Anyways we can use GWT to solve this issue. DialogBox class there handles this issue and the javascript generated through that is also browser independent.
Hi Sujeet,
Thanks for your response. Could you pls provide some links on GWT. How does the GWT produce javascript code? I would be interested to know.
Thanks,
Amar