dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Web
Expertise: Advanced
Aug 14, 2000

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Using Web Dialogs in IE

Opening a new browser window is a handy but sometimes misused feature. Eventually, your user ends up with tons of open browser windows they just forget about.

Sometimes a Web dialog will do the job better. There are two kinds of Web dialogs available: modal and modeless. Modal dialogs (available in IE 4+) will not let the user go back to the browser window until the dialog is closed. Modeless dialogs (IE5+) will let the user back to the browser, but the dialog will stay on top. Most users won't lose track of a Web dialog but will forget a new window.

Dialogs are great for getting a little more information from the users before performing an action. For example, if the user clicks a button to "Show my Purchase History," you may want to find out which product line to show. Pop up a modal dialog with a combo box and ask!

Here's how to open a modal dialog:

 window.showModalDialog("path/page.htm", null,
      "dialogHeight:100px; dialogWidth: 200px; help:yes; 
scroll:yes;"+ "resizable:yes")
You can even pass parameters back and forth. Substitute a value or variable name for the null in the second argument to showModalDialog (above). Then, to retrieve the value in the dialog, use:
 //this is in page.htm (the dialog)

   //retrieve the argument
   var theArg = window.dialogArguments

   //return a value to the calling window
   window.returnValue = "I'm a return value"
To catch the return value in the calling window, use:
 var theReturnValue = window.showModalDialog( etc... )
To create a modeless dialog, just change the code above to call the showModelessDialog method (IE5+). Again, modeless dialogs will let the user switch focus back to the calling browser window, but the dialog will still stay on top.

Dialogs can do almost anything that a Web page can do, so get creative!

(Note: Check out the MSDN references for modal dialogs and modeless dialogs.)

Chris McCann
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date