homepage Welcome to WebmasterWorld Guest from 54.204.217.249
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
JS cross browser print
toolman




msg:1474675
 11:50 pm on Jan 24, 2002 (gmt 0)

Is there a cross browser way to print?

 

tedster




msg:1474676
 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.

joshie76




msg:1474677
 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.


<html>
<head>
<title>OLECMDID</title>

<script>
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 PROMPT = 1; // 1 PROMPT & 2 DONT PROMPT USER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID,PROMPT);
WebBrowser1.outerHTML = "";
}
</script>
</head>
<body>
<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
</select>
<input type="Button" value="Go" onclick="printpr(document.form.olecmdid.value);">
</form>
</body>
</html>

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved