开发者

automatically printing page on form submit

i have been using the below code to automatically print out a form on submission but the problem i have encountered is that upon navigating away from the page, the "Submit - And Print" button stops working.

Secondly is there a way to bypass the print dialog on internet explorer/google chrome and allow the form to print automatically and the send the request to the printer automatically? there is also a need to remove all headers and footers from the pages pritned (i.e. internet explorer web page printing defaults).

<html>
<head>
<script language="javascript" type="text/javascript">

function PrintMeSubmitMe()
{
window.print();
SubmitMe();
}

function SubmitMe()
{
document.MyForm.submit();
}
</script>
</head>
<body>
<form name="MyForm" action="somepage.asp" method="post">
<input type="button" value="Submit - No Print" onclick="S开发者_JAVA百科ubmitMe()"><br />
<input type="button" value="Submit - And Print" onclick="PrintMeSubmitMe(this)"><br />
</form>
</body>
</html>

i have come to realise that the "submit - and print" bug occurs on google chrome only and not internet explorer


There is no way to bypass the print dialog.* If there was a way, it could be maliciously exploited far too easily. It would be a security nightmare.


*Without a browser plugin


On IE you can install a plugin from MeadCo (a UK based company) which includes an embedded object and comprehensive javascript interface to the printer that allows control of almost all aspects of printing. We have been using this solution for many years now and it would probably meet your needs of avoiding the print dialog, managing header/footer, etc.


If you are using chrome, you can disable print preview dialog.

1. Create shortcut of chrome
2. Go to properties
3. Add "--disable-print-preview" at the end of target
   or
   Add "--koisk-printing" at the end of target
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜