[英]Navigate to another page and print that page?
我有一个php脚本(process.php),我在其中完成所有工作并生成html这样的输出。
程序PHP
<?php
ob_start();
//Rest of my php code is here.
echo "FINAL";
file_put_contents('record.html', ob_get_contents());
ob_end_flush();
//it will write a file named 'record.html' in the same directory.
?>
现在,当我想要任何用户打开此process.php文件时,他将被重定向到record.html并自动显示打印选项。
无论用户是打印文档还是取消/关闭打印选项,都应自动关闭页面。
该代码将满足您的要求,但效率不是100%。 但是您可以将其用于工作。
setTimeout(function(){var ww = window.open(window.location, '_self');
ww.close()},100);
window.print();
是否有关于代码的查询超出要求。 谢谢
有多种方法可以执行此操作:加载此页面以进行打印时,您可以使用javascript window.print,然后可以使用window.location.href =“任何年龄段的链接(不包括年龄)此打印页面”,或者如果您想使用window.open(),则可以将此年龄段打开到另一个窗口。 也尝试一下。
window.print(); window.location.href =“另一个年龄”; //或window.close()完全关闭窗口
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.