Javascript HTML表单发布到直接打印页面
我有一个VIEW-SALE.PHP页面 在此页面上,我有一个提交按钮表单,用于以打印格式查看发票,代码如下:Javascript HTML表单发布到直接打印页面,javascript,php,html,css,printing,Javascript,Php,Html,Css,Printing,我有一个VIEW-SALE.PHP页面 在此页面上,我有一个提交按钮表单,用于以打印格式查看发票,代码如下: <span style='display:inline-block'> <form name='print' id='print' action='print-invoice.php' target='_blank' method='post'> <input type='hidden' name='invoice' va
<span style='display:inline-block'>
<form name='print' id='print' action='print-invoice.php'
target='_blank' method='post'>
<input type='hidden' name='invoice' value='$invoice'>
<input class='submit-all' type='submit'
value='Print the invoice'
onClick='window.print();return false'></form></span>
代码必须只打开PRINT-INVOICE.PHP页面并打印它,但当我单击它时,它会显示打印对话框,但当前页面的我是VIEW-SALE.PHP,因此它不会显示PRINT-INVOICE.PHP
如何做到这一点?不只是发布数据,您可能需要一个标题重定向,重定向是php代码
header("Location: blabla")
我找到了这个你会发现它有帮助的
问题在于
onClick='window.print();返回false'
。窗口
对象是包含表单的当前窗口。您应该在PRINT-INVOICE.PHP中包含一个javascript事件处理程序:
... <body onload="window.print()"> ...
。。。