Learn how to write to a window
Takeaway: The content of a subwindow does not need to reside in its own HTML file. Find out how you can write to a window.
By Brent Lee Metcalfe
The content of a subwindow does not need to reside in its own HTML file. Let me illustrate.
The content for this example, including the graphic, was written to the window when the window was opened. There are seemingly innumerable ways to do this. Here's one:
var writeWin = null;
After defining the window (writeWin) in function writeLeft(), variable ePen is set as an HTML string. Additional strings are concatenated using the add-by-value operator (+=). Then a new document is initialized in window writeWin using the document open() method. The variable ePen is passed to the document write() method, which writes out the concatenated strings.
Note that you must use the document close() method to end the output stream or the document will not display.
Brent Lee Metcalfe is a Web architecture consultant.
function writeLeft() { writeWin =
window.open('','aWin','top=0,left=0,width=250,height=350'); var ePen =
'<html><head><title>sans .html file</title></head>'; ePen += '<body
text="#cccccc" bgcolor="#000000"><tt><p>once upon a time, a ghost
said:</p>'; ePen += '<p><center><img
src="graphics/boo.jpg"></center></p><p>the end.</p></body></html>';
var wd = writeWin.document;
wd.open();
wd.write(ePen);
wd.close();
}
SponsoredWhite Papers, Webcasts, and Downloads
- Live Webcast: Web Threats Don't Discriminate - Large and Small IT Departments Need to be Equally Prepared IronPort Systems
- Live Webcast: Optimized Virtualization ZDNet
- Yankee Group: Exploring the Benefits of 3G Wireless Integrated into Business-Class Routers Sprint
- Outsourcing Your Infrastructure: Ten Points to Consider When Making the Move Verio
- SprintSecure Message Protection Fact Sheet Sprint
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





