window.open / window.print

D

dan

This works in mozilla but I can't figure out why this won't work in
IE.


Say I have this html


<html>
header goes here
header goes here
header goes here
header goes here
header goes here


<div id="thecontent">
html goes here
tables etc
html goes here
html goes here
html goes here
<tag><tag><tag>
</div>

<img src="url" onclick="printIt()">



footer html goes here
footer html goes here
footer html goes here
footer html goes here

</html>


the printIt function looks like this



function printIt()
{
//grab the div in the html w/o the header & footer text
content=document.getElementById('thecontent');

//open a blank window
w=window.open('about:blank');

//write content var html to the window
w.document.write( content.innerHTML );

//write some javascript to make the newly opened window print itself.
w.document.writeln("<script>");
w.document.writeln("window.print()");
w.document.writeln("</"+"script>");
}


This will cause the print dialog to pop up in mozilla but doesnt
prompt to print in IE.


Is this a security issue?
 
T

Tim Williams

<html>
<script type="text/javascript">
function printIt()
{
//grab the div in the html w/o the header & footer text
var content=document.getElementById('thecontent');
//open a blank window
w=window.open('about:blank');
//write content var html to the window
w.document.open();
w.document.write("<html>" + content.innerHTML);
//write some javascript to make the newly opened window print itself.
w.document.writeln("<script>window.print()</"+"script>");
w.document.writeln("</html>");
w.document.close();
}
</script>
header goes here<br />header goes here<br />
header goes here<br />header goes here<br />
header goes here<br />
<div id="thecontent">
html goes here<br />tables etc<br />
html goes here<br />html goes here<br />html goes here<br />
</div>
<img src="url" onclick="printIt()">
</html>

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,219
Latest member
Geraldine7

Latest Threads

Top