I am trying to create a printer friendly page. We've got that sorted using thirdparty software that snapshots the page and spits out image files. Now we have created a link to the image page and would like to create a javascript that opens print preview directly.
I have found two javascripts first to open in a new page and another one to open print preview .This all works on IE 9. I need to combine these two javascripts :-)
I have tried anything I know to combine them without success.. Could I please get some help from the gurus? :-)
First script:
function printpage(url)
{
child = window.open(url, "", "height=1, width=1"); //Open the child in a tiny window.
window.focus(); //Hide the child as soon as it is opened.
//child.print(); //Print the child. <-- I need this to call PrintPreview()
child.close(); //Immediately close the child.
}
Second script the print Preview part
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>';
window.document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}
Any help is very much appreciated.