On MovieTome: TRANSFORMERS 2 SPOILERS!

Prevent window orphans

Tags: Guest Contributor

  • Save
  • Print
  • 0

Takeaway: There are times when breaking the object hierarchy is harmless, if not desirable. Here's how to create a transitional pop-up window that automatically closes when it launches a new window.

By Brent Lee Metcalfe

This tip is a warning: If you open a secondary window and a tertiary window that is a child to the secondary window, then close the secondary window; the secondary window's parent can no longer control the tertiary window. Closing an intermediate window severs the (object) hierarchical relationship between both the parent and child windows of the intermediate window.

That said, there might be occasions where breaking the object hierarchy is harmless, if not desirable. Consider a transitional pop-up window that automatically closes when it launches a new window.

The secondary pop-up window includes a function that tests whether the tertiary window is already open:

var whoAmI = navigator.appName;

function transitory(url) {
  var hobo = window.open(url,'bum','scrollbars,resizable,width=640,height=340,left=40,top=40');
  if (hobo != null) window.close();
  if (whoAmI == 'Netscape' && hobo != null) hobo.focus();
}

When the tertiary window opens, the secondary pop-up window closes. If the tertiary window is already open, function transitory() does some browser-specific focusing."

If you set the variable for the tertiary window's open() method to null, you'll generate an error in IE 4.x. Carefully weigh the tradeoffs of breaking the window object hierarchy.

Brent Lee Metcalfe is a Web architecture consultant.

  • Save
  • Print
  • 0

What do you think?

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET
advertisement
Click Here