Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

6. Managing Browser Windows > 6.10. Simulating a Cross-Browser Modal Dialog Win...

Simulating a Cross-Browser Modal Dialog Window

Problem

You want to present a consistent modal dialog on multiple browsers.

Solution

Although IE provides the showModalDialog() method, no other browser supports it, except Safari. This recipe uses a browser subwindow to simulate the behavior of a modal dialog box. It operates in IE 4 or later, Mozilla, Safari, and Opera 7 or later. Note that this is a simulation of true modality. Due to some odd behavior in IE for Windows with respect to disabling hyperlinks in the main window, a determined user can bypass the modality of this solution. For casual users, however, the window behaves much like a modal dialog box.

Assemble your main HTML page around the simModal.js script library described in the Discussion. This library works by disabling form controls and links in the main page after the modal dialog is displayed and making sure the dialog keeps the focus, so that the user is forced to deal with the dialog. After the dialog is dismissed, the form controls and links are enabled again. All of this work occurs through a single dialogWin object defined in the library.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint