It was required to print a page with different domain. Where my javascript failed to communicate cross domain using frames. I got below mentioned print preview code when i searched on net. It solved my prblem however it only worked for IE. It didnt worked for Mozilla Firefox.
Below mentioned code works only for IE.
<html>
<head>
<title> print preview </title>
<script type="text/javascript">
function showPrintPreview()
{
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>
<h1>print preview</h1>
<h2>print preview</h2>
<h3>print preview</h3>
<a href="#" onclick="showPrintPreview()">print preview</a>
</body>
</html>
I then searched how to get the same functionality in mozilla. I tried the below mentioned codes but it didn't worked any
nsiwebbrowserprint::print();
nsiwebbrowserprint::getglobalprintsettings();
nsiwebbrowserprint::printpreview();
nsiwebbrowserprint::printpreviewnavigate();
nsiwebbrowserprint::exitprintpreview();
Hope any one gets this solution.
Below mentioned code works only for IE.
<html>
<head>
<title> print preview </title>
<script type="text/javascript">
function showPrintPreview()
{
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>
<h1>print preview</h1>
<h2>print preview</h2>
<h3>print preview</h3>
<a href="#" onclick="showPrintPreview()">print preview</a>
</body>
</html>
I then searched how to get the same functionality in mozilla. I tried the below mentioned codes but it didn't worked any
nsiwebbrowserprint::print();
nsiwebbrowserprint::getglobalprintsettings();
nsiwebbrowserprint::printpreview();
nsiwebbrowserprint::printpreviewnavigate();
nsiwebbrowserprint::exitprintpreview();
Hope any one gets this solution.