[英]How to open print in new window?
when i click print it redirects to print in same window thus loosing original receipt.What should i add in below code so that it opens in new window 当我单击打印时,它会重定向到同一窗口中进行打印,从而失去原始收据。我应该在下面的代码中添加些什么,以便它在新窗口中打开
<div class="print_img">
<button onclick="myFunction()">
<div align="justify">Print</div>
</button>
</div>
<script>
function myFunction() {
window.print();
}
</script>
<style>
@media print {
.print_img {
display:none;
}
}
function myFunction() {
var thePopup = window.open( '', "My Popup", "menubar=0,location=0,height=700,width=700" );
$('#popup-content').clone().appendTo( thePopup.document.body );
thePopup.print();
}
Try to modify your function like this 尝试像这样修改您的功能
Try this : 尝试这个 :
var newWindow=window.open('','','width=200,height=100');
newWindow.document.write("<p>Append here your text/html</p>");
newWindow.document.close();
newWindow.focus();
newWindow.print();
newWindow.close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.