在 HTML 中,文档打印完成后执行脚本?

htmlweb developmentfront end technology更新于 2025/8/18 1:16:17

使用 HTML onafterprint  属性,在文档打印完成后或打印过程中执行脚本。

示例

您可以尝试运行以下代码来实现 onafterprint  属性 −

<!DOCTYPE html>
<html>
   <body onafterprint = "display()">
      <script>
         function display() {
            alert("Success!");
         }
      </script>
   </body>
</html>

相关文章


有用资源