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


Create and Destroy

January 19, 1999

Create and destroy -- spawning the pop up window and cleaning up after it.
function popIt()
{ popWin=window.open
	("popups.html","PopUp",
	"toolbar  	= no,
	location   	= no,
	directories	= no,
	status		= no,
	menubar		= no,
	scrollbars	= no,
	resizable  	= yes,
	dependent  	= yes,
	alwaysRaised	= yes,
	width		= 250,
	height		= 100");
  popWin.resizeTo(0,0);self.focus();}

function cleanUp()
{ if(!popWin.closed) {popWin.close();} }

//startup script
if (popAble) {
 crossBrowser();
 popIt();
 self.focus();
 window.onunload = function (e) {cleanUp()};
}

// end hiding code -->

</script>

<!-- end of pop up code -->

When the client's original page loads, embedded with the mission control script, it launches the popIt() function as called by the statement in the "startup script" section above. Very simply, popIt() spawns the menu window and, by bringing focus to the main browser window, effectively hides the menu. Resizing the spawned window to 0 by 0 is only effective in Internet Explorer, which minimized the window off the desktop; Navigator simply ignores the request because it refuses to size a window smaller than 100 by 100 pixels. Notice in the window.open() parameters that the feature dependent is set to yes. This causes the spawned menu window to be a "dependent" window which, as its namesake implies, is not totally independent. Specifically, in Netscape, a dependent window will close when its parent window closes. According to the Internet Explorer developer documentation, a dependent window should not contain a close gadget or appear on the Windows taskbar -- however, it does both because the dependent feature is apparently broken or not implemented in Internet Explorer 4 (moral: don't believe everything you read!).

Recall that the boolen popAble is only true if the browser is version 4+ and running in Windows, and so this check prevents the mission control script from attempting to execute on an inappropriate platform.

Good etiquette suggests that it's proper to clean up after oneself and DHTML is no exception. Should the user leave the page which spawned the pop-up menu window we should be sure to get rid of the spawned window. The function cleanUp() does just that, and is called via an onUnload event handler set for the page in the final line of the startup script.

Action Hero
DHTML Pop-Up Menus: A Parable of Triumph and Loss (Based on a True Story)
Rigging the imagemap to trigger the pop-ups.


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