English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
When the document related to the page is about to be printed or previewed for printing, the beforeprint event is triggered.
When the page is to be printed, JavaScript is executed :
<!DOCTYPE html> <html> <head> <title>HTML onbeforeprint event property usage(basic tutorial site oldtoolbag.com)</title> <body onbeforeprint="myFunction()"> <h1>Try to print this document</h1> <p><b>Tip:</b> Keyboard shortcuts, such as Ctrl+P sets the page to print.</p> <p><b>Note:</b> The onbeforeprint event is not supported in Safari and Opera.</p> <script> function myFunction() { alert("You are about to print this document!"); } </script> </body> </html>테스트해 보세요 ‹/›
IEFirefoxOperaChromeSafari
현재 Internet Explorer와 Firefox 브라우저만이 onbeforeprint 이벤트 속성을 지원합니다.
打印页面即将出现(在打印对话框出现之前),将触发onbeforeprint 속성。
참고: onbeforeprint 속성은 onafterprint 속성과 함께 사용되는 경우가 많습니다
onbeforeprint 속성은 HTML5새 속성.
<element onbeforeprint="script">
값 | 설명 |
---|---|
script | onafterprint에서 실행되는 스크립트. |