Home  >  Article  >  Web Front-end  >  Execute script after printing document in HTML?

Execute script after printing document in HTML?

WBOY
WBOYforward
2023-08-27 21:21:061368browse

Execute script after printing document in HTML?

Use the HTML onafterprint attribute to execute the script after the document prints or is being printed.

Example

You can try running the following code to achieve onafterprint Attribute -

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

The above is the detailed content of Execute script after printing document in HTML?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete