I am working with IE8, in an environment where ActiveX is not allowed by group policy. I have a print bar I want to display with links that launch the Print and Print Preview dialogs. Is there an alternative to this code that doesn't require ActiveX? I just need a script that will launch the Print Preview dialog.
All my users are using Internet Explorer 8 on Windows 7 workstations.
<script type="text/javascript">
function PrintPreview()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 0 - open window
* 4 - Save As
*/
var PROMPT = 1; // 1 PROMPT USER 2 DON'T 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>
<div class=HideDuringPrint id=divHideMe>
<font size=2>
<strong>
<div style="float: left">
<a href="javascript:window.print()">
Print
</a>
<a href="javascript:window.PrintPreview()">
Preview
</a>
</div>
<div style='clear: both;'></div>
</strong>
</font>
</div>