spacer
Yehuda Shiran August 30, 2001
Using the Caller's Method from within the Dialog Box
Tips: August 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

When you call a dialog box with either showModalDialog() or showModelessDialog(), you can use the second parameter to pass information from the caller to the callee and vice versa. Suppose you have a function definition in the caller, and you want to call the function from within the callee. You know that all functions are methods of the window object. You need to pass the window object to the callee, and then have the callee call the particular method.

Here is how you call the dialog box:

showModelessDialog("010828b.html",window,
   "status:false;dialogWidth:300px;dialogHeight:150px");
Notice the window object in the second position. The callee reads in the second parameter into the dialogArguments variable. It can be a scalar, an array, an object, etc. In the following example the callee first assigns dialogArguments to the callerWindowObj, and then calls the update() method of this object:

  var callerWindowObj = dialogArguments;
  callerWindowObj.sColor = oEnterColor.value;
  callerWindowObj.update(); 
The function update() is defined in the caller as:

function update()
{
  oColor.innerText = sColor;
}
For more on modal and modeless dialog boxes, go to Column 90, Modal and Modeless Dialog Boxes.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business