onbeforeprint
屬性事件是當頁面即將打印時或在打印對話框出現(xiàn)前觸發(fā)。
onbeforeprint
屬性是HTML5中的新特性。
<element onbeforeprint="script or javascript function name">
<body>
![]() |
![]() |
![]() |
![]() |
![]() |
|
---|---|---|---|---|---|
onbeforeprint |
Yes | Yes | Yes | Yes | Yes |
<!DOCTYPE html>
<html>
<body onbeforeprint="myFunction()">
<h1>Try to print this document</h1>
<script>
function myFunction() {
alert("print");
}
</script>
</body>
</html>
更多建議: