Html5 use to perform certain scripts after the event enables the printing onafterprint

: This article is reproduced in apes 2048 website ⇛ perform certain scripts after the event enables the printing Html5 use onafterprint

Examples

After setting the printed page and the Print dialog box has appeared, the implementation of a JavaScript:

<body onafterprint="printmsg()">

Browser support

IE Firefox Chrome Safari Opera

Only Internet Explorer and Firefox support onafterprint event attributes.

Note: In IE, onafterprint property occurs in the Print dialog box appears before rather than after.

Definition and Usage

onafterprint property occurred in the user settings page and print after print dialog box has appeared.

Tip: onafterprint property is often used in conjunction with onbeforeprint property.

The difference between HTML 4.01 and HTML5

onafterprint attribute is new in HTML5 attributes.

grammar

<elementscript">

Property Value

value description
script Onafterprint occurs when the script runs.
  Example:
<!DOCTYPE html>
<html>
<head>
<script>
function printmsg()
{
alert ( "This document now being printed!");
}
</script>
</head>

<body>

<H1> Try to print this document. </ H1>
<P> <b> Tip: </ b> keyboard shortcuts, such as Ctrl + P print setting page. </ P>
<P> <b> Comment: </ b> Internet Explorer and Firefox support onafterprint property. </ P>
<P> <b> Note: </ b> In IE, onafterprint property occurs before rather than after the print dialog box appears. </ P>

</body>
</html>


More professional front-end knowledge, make the [2048] ape www.mk2048.com

Guess you like

Origin www.cnblogs.com/htmlandcss/p/11741766.html