在这里,我有用于打印和打印预览的工作代码,但它在Mozilla 中不起作用。请让我知道我是如何让它在 mozilla 中工作的。我希望打印预览与 irctc 网站一样。
<html>
<head>
<title>Print Preview</title>
<style type="text/css">
@media print {
.noPrint {
display:none;
}
}
</style>
<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 runat="server">
<asp:radiobutton ID="Radiobutton1" class="noPrint" runat="server"></asp:radiobutton>
<asp:textbox ID="Textbox1" runat="server"></asp:textbox>
<asp:checkboxlist ID="Checkboxlist1" class="noPrint" runat="server">
<asp:ListItem>gsdghsg</asp:ListItem>
<asp:ListItem>ggsgh</asp:ListItem>
<asp:ListItem Value="gdfgg">gfghghgf</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:checkboxlist>
<div class="noPrint"><asp:textbox ID="Textbox2" runat="server"></asp:textbox></asp:checkboxlist></div>
<input type='button'class="noPrint" value="Print Preview" onclick="printpr();">
</form>
</body>
</html>