On ZDNet: 64-bit Windows goes mainstream

Learn how to write to a window

Tags: Guest Contributor

  • Save
  • Print
  • 0

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;
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();
}

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.

  • 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

The PC Cracked Open

advertisement
Click Here