Click to See Complete Forum and Search --> : printing a file


webtekie
01-08-2004, 04:21 PM
Hi guys,

Is it possible to print a file from HTML page that is located on the server?

thanks,
webtekie

fredmv
01-08-2004, 04:23 PM
<script type="text/javascript">
//<![CDATA[
var w = window.open('http://www.foo.com/file.html');
w.print();
//]]>
</script>

webtekie
01-08-2004, 04:32 PM
thanks, but why do you use CDATA?

webtekie
01-08-2004, 04:46 PM
also, is it possible to bypass opening a new window and just open 'Print Dialog'?

fredmv
01-08-2004, 06:48 PM
Originally posted by webtekie
thanks, but why do you use CDATA? It's only really important if you're using an XHTML DOCTYPE and have embedded JavaScript. I've explained why in this post (http://www.webxpertz.net/forums/showthread.php3?s=&threadid=27224#post147808).Originally posted by webtekie
also, is it possible to bypass opening a new window and just open 'Print Dialog'?
You could simply close the window after by doing this:w.close();However, you could also print an iframe.

webtekie
01-09-2004, 07:49 AM
really? How do I prnit an iframe?

fredmv
01-09-2004, 07:55 AM
<iframe src="foo.html"></iframe>
<a href="#" onclick="document.getElementsByTagName('iframe')[0].contentWindow.print();">Print iframe...</a>