faqts : Computers : Programming : Languages : JavaScript : Document

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

42 of 53 people (79%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I print a document that was generated using document.write() ?

Jun 28th, 2000 10:53
Chris Durkin,


Make sure that the document.write statements are enclosed in 
document.open() and .close() 
See example below 
 var win1 = window.open("", "Example1");
 win1.document.open();
 win1.document.write("<head><title>Print Me</title></head>");
 win1.document.write("This page will print properly, ")
 win1.document.write("even though it was dynamically generated.")
 win1.document.close();
 var win2 = window.open("", "Example2");
 win2.document.write("<head><title>Print Me</title></head>");
 win2.document.write("This page won't print.")