Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Action Hero

January 19, 1999

Action hero: once conditions are met the menu window is prepped and popped.
function popIndex(topic,mouseX,mouseY)
{ 

if (popWin.closed) 
   {popIt();popWin.blur();} 
if (popWin.setupComplete) 
  {popIndex2(topic,mouseX,mouseY)} 
}
function popIndex2(topic,mouseX,mouseY)
{   
  
  if (clearPop!=0)
  	{popWin.clearTimeout(clearPop);
	popWin.clearTimeout(popWin.clearPop2);}
  clearPop=popWin.setTimeout
  	("self.resizeTo(0,0);
	opener.focus()",5000);
  
//clear any open pop topic
  if (opentopic!=null)
  { var oldobjName="['"+opentopic+"']";
    eval(obj+oldobjName+visibility+invisible);} 
  
  var objName="['"+topic+"']";
  
  //adjust window dimensions to match popup index
  if (document.all)
  // { popWin.resizeTo
  	(eval(obj+objName+posWidth)+30,eval(obj+objName+posHeight)+50) }
  {popWin.resizeTo(250,popWin.document.all[topic].clientHeight+45);}
  else { popWin.innerHeight=eval(obj+objName+posHeight); }
  
  eval(obj+objName+visibility+visible);
  opentopic=topic;
  
    popWin.moveTo(mouseX+50,mouseY-25);
  popWin.focus();
}

Inching ever closer to the action-packed center of these scripts, popIndex() is the function called when the user passes the mouse pointer over a topic link in the table of contents. Ideally, this will lead to the pop-up menu appearing; the popIndex() function, though, is a "protection" function which ensures that conditions are correct before actually launching the pop-up.

Specifically, popIndex() checks on two conditions: first, is the pop-up menu window still open? This protection serves to check user interference, in case the user has manually closed the menu window (which they shouldn't but we can't stop them). If the menu window has been ruthlessly closed by the user then it is immediately re-spawned. Second, it's vital that the menus inside the menu window have all been setup -- remember the setup() function in popups.html? The popups.html script will set the variable setupComplete to true when the menus are ready, and so we only continue on to launching the menu if this is so.

The subsequent function popIndex2(), then, is the real captain of the mission control center, doing the dirty work, as they say. First things first, popIndex2() sets up the timeouts which control disappearance of the menu (rule #1, seen earlier). If a previous topic's menu has already been popped that menu is cleared (set to invisible) within the menu window. Turning the script's focus to the topic menu to be popped, the menu window's size is adjusted to fit the size of the menu. Within Internet Explorer both horizontal and vertical dimensions of the menu window are adjusted; within Navigator only the vertical height may change due to a quirk wherein horizontal window adjustments cause the menu window to reload with negative consequences.

All set for launch, the layer which contains the topic menu is set to visible using the eval() technique relying upon the common DHTML terms defined by crossBrowser(). The currently open topic is now registered with opentopic and the window is moved into correct position on the screen relative to the location of the user's mouse when it originally passed over the table of contents topic link.

The last line of popIndex2() is the final sparkle on the shine, actually causing the pop-up menu window to "appear":

popWin.focus();

Once the menu window gains focus then its own scripts, within popups.html, take over control.

Building the Imperfect Beast: Part 3 (embedded mission control)
DHTML Pop-Up Menus: A Parable of Triumph and Loss (Based on a True Story)
Create and Destroy


Up to => Home / Authoring / DHTML / Menus




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers