JS onbeforeprint属性
onbeforeprint属性
JavaScript window对象的onbeforeprint属性,可以在窗口被打印或被打印预览之前激活。
语法
window.onbeforeprint = function
onbeforeprint属性实例代码,及在线编辑器
在线运行完下方实例之后,可以点击右键,选择打印当前网页,看看效果:
<script>
window.onbeforeprint = function(){
alert("网页即将被打印")
}
</script>