Set a window variable to null
Takeaway: If you're working with JavaScript windows, you may need to set a windows variable to null at some point in time. Here's how.
By Brent Lee Metcalfe
Let's get what may seem like the most trivial tip--but the most important tip overall--out of the way. Before you declare a variable for a window open() method, declare it as a global variable and set it to null. Something similar to this:
<html>
// window conditions and statements go here
}
If you don't implement this simple tip, crucial windowing code will fail. Setting a global variable to null lets you query the value of a corresponding local variable before the local variable has (or no longer has) a value.
Brent Lee Metcalfe is a Web architecture consultant.
<head>
<script language="JavaScript">
<--
var windowVariable = null;
function launchWindow() {
windowVariable = window.open();
//-->
</script>
SponsoredWhite Papers, Webcasts, and Downloads
- Identifying Common Reliability/Stability Problems Caused by File Fragmentation Diskeeper
- Does fragmentation affect SANs, NAS, and RAID? Diskeeper
- The Seven Types of Power Problems American Power Conversion (APC)
- Is Real-Time Defragmentation Needed in Today's Environment? Diskeeper
- Live Webcast: Save Time, Money and Manpower While Eliminating Redundancies from Your Data Backups PC Connection
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

