Prevent window orphans
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) {
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.
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();
}
SponsoredWhite Papers, Webcasts, and Downloads
- Webcast: How to Get the Most Out of Microsoft Windows Deployments with Intelligent iSCSI Storage Dell EqualLogic
- Live Webcast: Web Threats Don't Discriminate - Large and Small IT Departments Need to be Equally Prepared IronPort Systems
- 10 Deadly Sins of Software Estimation Construx Software Builders
- Software Development's Classic Mistakes 2008 Construx Software Builders
- Outsourcing Your Infrastructure: Ten Points to Consider When Making the Move Verio
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

