Hello !! Anybody to know to how to print a document ? I have used the next JavaScript code: <script language="javascript"> window.print(); </script> But, it only is valid for Netscape and it is not valid for Microsoft Internet Explorer. Exists any way to print a document from ZOPE or trought JavaScript ? Thanks. ------- Juan Javier Carrera Obrero e-mail: jcarrera@uco.es
On Fri, 14 Apr 2000, Juan Javier Carrera Obrero wrote:
<script language="javascript"> window.print(); </script>
But, it only is valid for Netscape and it is not valid for Microsoft Internet Explorer.
Few days ago I saw it worked in M$ IE 5.0 (I am working on a site where there will be Print button, and I tested few browsers - work in Linux and Windows, in Netscape and Exploder...) Oleg. ---- Oleg Broytmann http://members.xoom.com/phd2.1/ phd2@earthling.net Programmers don't die, they just GOSUB without RETURN.
Oleg Broytmann wrote:
On Fri, 14 Apr 2000, Juan Javier Carrera Obrero wrote:
<script language="javascript"> window.print(); </script>
I think you want to inlude type="text/javascript" in the <SCRIPT> tag, to make it forwards compatible.
But, it only is valid for Netscape and it is not valid for Microsoft Internet Explorer.
Few days ago I saw it worked in M$ IE 5.0 (I am working on a site where there will be Print button, and I tested few browsers - work in Linux and Windows, in Netscape and Exploder...)
I think it's possible to include vbscript as an alternate IE solution. I've seen fairly old IE's printing automagically, don't remember what version. Regards, Morten
Juan Javier Carrera Obrero wrote:
Exists any way to print a document from ZOPE or trought JavaScript ?
The following code should work in Netscape 4.0, IE 4.0 (Windows), IE 5.0. It looks scary cause IE4.0 doesn't support window.print(), while using VBScript will cause a download to start in IE5 if you haven't installed VBScript. Scary, isn't it? function printPage() { if (pr) // NS4, IE5 window.print() else if (da && !mac) // IE4 (Windows) vbPrintPage() else // other browsers alert("Sorry, your browser doesn't support this feature."); return false; } if (da && !pr && !mac) with (document) { writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'); writeln('<' + 'SCRIPT LANGUAGE="VBScript">'); writeln('Sub window_onunload'); writeln(' On Error Resume Next'); writeln(' Set WB = nothing'); writeln('End Sub'); writeln('Sub vbPrintPage'); writeln(' OLECMDID_PRINT = 6'); writeln(' OLECMDEXECOPT_DONTPROMPTUSER = 0'); writeln(' OLECMDEXECOPT_PROMPTUSER = 1'); writeln(' On Error Resume Next'); writeln(' WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER'); writeln('End Sub'); writeln('<' + '/SCRIPT>'); }
Oops. Here's the full code: var da = (document.all) ? 1 : 0; var pr = (window.print) ? 1 : 0; var mac = (navigator.userAgent.indexOf("Mac") != -1); function printPage() { if (pr) // NS4, IE5 window.print() else if (da && !mac) // IE4 (Windows) vbPrintPage() else // other browsers alert("Sorry, your browser doesn't support this feature."); return false; } if (da && !pr && !mac) with (document) { writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'); writeln('<' + 'SCRIPT LANGUAGE="VBScript">'); writeln('Sub window_onunload'); writeln(' On Error Resume Next'); writeln(' Set WB = nothing'); writeln('End Sub'); writeln('Sub vbPrintPage'); writeln(' OLECMDID_PRINT = 6'); writeln(' OLECMDEXECOPT_DONTPROMPTUSER = 0'); writeln(' OLECMDEXECOPT_PROMPTUSER = 1'); writeln(' On Error Resume Next'); writeln(' WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER'); writeln('End Sub'); writeln('<' + '/SCRIPT>'); }
participants (4)
-
Itamar Shtull-Trauring -
Juan Javier Carrera Obrero -
Morten W. Petersen -
Oleg Broytmann