Friday, August 24, 2007
Javascript function handling Print, Print Preview.
I have seen many developers looking for the print, print preview and related problems. Below is a good javascript function solving this purpose based on the value of OLECMDID parameter. It also has the option for suppressing the option for promting the end user.
<html>
<head>
<script>
function printpr()
{
var OLECMDID = 7;
//var OLECMDID = 20;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '';
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>
Subscribe to:
Post Comments (Atom)
2 comments:
what is webbrowser1
what is web Browser1
Post a Comment