spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column37


JavaScript and Frames, Part II (5)

Vice President of Risk Technology - READY TO HIRE! (NYC)
Next Step Systems
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


Handling Mouse Clicks

We put an event handler for mouse clicks in the bottom frame:

</SCRIPT>
</HEAD>
<BODY>
  <A HREF="javascript:void(0)" onClick="handleClick()"><IMG SRC="doc.gif"
       WIDTH="50" HEIGHT="50" BORDER="0"></A>
</BODY>
</HTML>

The event handler handleClick() is defined via a function that is included in the top frame:

function handleClick() {
  top.findClickedBox(self);
}

The findClickedBox() function (included in the top frame) finds which frame had been clicked:

function findClickedBox(boxObject) {
 for (var i = 0; i < dim1; i++) {
  for (var j = 0; j < dim2; j++) {
   if (boxObject == top.frames[i].frames[j]) {
     rowFound = j;
     colFound = i;
     if (blockClicking == false)
     if (top.frames[i].frames[j].document.images[0].src.indexOf(blank) == -1)
       revealBox(rowFound, colFound);
     return;
   }
  }
 }
}

We pass the self object from the lowest frame to the top frame. The self object is like an ID by which we can identify the clicked box. We go over all 64 frames and check for equality between their frame objects and the object passed from the clicked box. Once we determine the clicked frame, we set the rowFound and colFound variables. We then check that clicking is allowed (blockClicking is false) and that the card is not removed (image is blank). If all conditions above are satisfied, we reveal the box:

            revealBox(rowFound, colFound);


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

Created: April 5, 1999
Revised: February 3, 2000

URL: http://www.webreference.com/js/column37/click.html