Answer
Hope this helps:
<html>
<head>
<title>Print Preview</title>
<script>
function printpr()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
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>
<input type='button' value="Print Preview" onclick="printpr();">
</form>
</body>
</html>
Is this item
helpful? yes no
Previous votes Yes: 2 No: 0
|
|
Comments and alternative answers
 |
 |
Re[2]: Print Preview in JavaScript
Sudhakara TP, Sep 7, 2004
Hi,
Its works perfectly. But now I have another problem in that. I have an hyperlink in my page onclick of that will close the window and in the same page, I have a print button on click of which i need to display the print preview for which i have used the code.
Now, when i generate the print preview i need to hide these hyperlinks on the page and to do this task, i am temporarily hiding these hyperlinks, generating the print preview & then showing these hyperlinks. Till here everything is working perfectly.
Now, when I generate the print preview, and when I click on the close button in the print preview window, click on the goback hyperlink, the window is being closed.
In the other hand, when i generate the print preview, close the print preview window by clicking on the closable button on the title bar, click on the goback button, the window is not getting closed.
Not able to figure out the problem.
Could any one help me on this.
My email id is spotsudhi@yahoo.com
Expecting an early reply from you
Regards
Sudhakara.T.P.
Is this item
helpful? yes no
Previous votes Yes: 0 No: 0
|
|

|
 |
Print preview with framed pages
Igor Portnoy, Aug 20, 2002
When I try to use this code on a page that is a part of frameset, the print preview shows the whole frameset, and not just the page on which this script is located. Is there way to modify this script to just preview the page on which it is located and not the whole frameset?
Is this item
helpful? yes no
Previous votes Yes: 2 No: 0
|
|

|
 |
Getting error
Priyadarshi Soumendra, Apr 13, 2004
Hi,
I have used the code.But I am getting insertAdjacentHTML method is not a function.
I am very new to javascript.So kindly suggest me what to do next?
Regards,
Soumendra
Is this item
helpful? yes no
Previous votes Yes: 0 No: 0
|
|

|
|
|
 |
|