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
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint