Solved

Is it possible to invoke print preview with javascript?

Posted on 2002-05-01
6
20,173 Views
Last Modified: 2011-08-18
I know it's possible to invoke the print dialog on IE 6 and Moz 6 with window.print().  Is it possible to invoke the "print preview" feature?  I tried window.printPreview(), but it didn't work...
0
Comment
Question by:mraible
6 Comments
 
LVL 1

Expert Comment

by:rajeev1972
ID: 6985247
In my opinion its not possible...
0
 
LVL 15

Accepted Solution

by:
a.marsh earned 50 total points
ID: 6985389
Came across this:

<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>


Got it from:

http://www.jguru.com/faq/view.jsp?EID=490852

Give it a try and let us know how you get on. :o)

Ant
0
 
LVL 1

Author Comment

by:mraible
ID: 6986119
Even though this is an IE-only feature - I like it - go with the market share eh ;)

Related to this, how is it possible to print just a frame or iframe.  window.frames.iframeName.print() doesn't seem to work.

Thanks,

Matt
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 15

Expert Comment

by:a.marsh
ID: 6986144
Try using:

parent.frameName.print()


Ant
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8255982
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

points to a.marsh
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
0
 

Expert Comment

by:modulo
ID: 8322050
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question