源代码:
下载代码
AI 编程工具
点击运行
<!DOCTYPE html> <html> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> <head> <script> function printmsg() { alert("你现在要打印该文档!"); } </script> </head> <body onbeforeprint="printmsg()"> <h1>打印文档</h1> <p><b>提示:</b> 快捷键, 如 Ctrl+P 设置打印页面。</p> <p><b>注意:</b> 目前只有 Internet Explorer 和 Firefox 浏览器支持 onafterprint 事件属性。</p> </body> </html>
运行结果: