homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

JS cross browser print

WebmasterWorld Senior Member 10+ Year Member

Msg#: 36 posted 11:50 pm on Jan 24, 2002 (gmt 0)

Is there a cross browser way to print?



WebmasterWorld Senior Member tedster us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 36 posted 12:08 am on Jan 25, 2002 (gmt 0)

I think it depends on how complete you want the compatibility to be. I'd guess that there are OS anomalies to deal with, as well as browser versions.

Here's a link for javascript printing [developer.irt.org] from NN4+ and IE5+. It also includes vbscript for IE3 and IE4.


WebmasterWorld Senior Member 10+ Year Member

Msg#: 36 posted 1:53 pm on Jan 28, 2002 (gmt 0)

I just thought I'd add this here for reference and interest. You can also deal with IE4 using javascript with the following code (IE only), this is interesting as you can also invoke other windows dialogs like print preview, page setup, save page as etc directly from your page using javascript. Copy the following code into your editor and preview in IE4+... I'm sure most of you can work out what's going on in the source.


function printpr(OLECMDID)
//var OLECMDID = 10;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 8 - page setup (for printing)
* 1 - open window
* 4 - Save As
* 10 - properties
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.outerHTML = "";
<form name="form">
<select name="olecmdid">
<option value="6">Print
<option value="7">Print Preview
<option value="8">Page Setup for printing
<option value="1">Open File
<option value="4">Save this web page as....
<option value="10">View the properties of this file
<input type="Button" value="Go" onclick="printpr(document.form.olecmdid.value);">

You can get a full list of OLECMDID values from here [msdn.microsoft.com] though not all will work depending on the available functions in your browser.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved