js 触发打印操作

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
  </head>
  <body>
    <button onclick="clickHandler()">print</button>
    <script>
      function clickHandler() {
        if (typeof window.print === "function") {
          window.print();
        } else {
          alert("您的设备不支持打印操作");
        }
      }
    </script>
  </body>
</html>
原文地址:https://www.cnblogs.com/aisowe/p/15245915.html