window.onbeforeunload vs window.print in Internet Explorer
window.onbeforeunload vs window.print in Internet Explorer
我的一个页面显示了折扣代码,如果你试图导航离开,我会使用window.onbeforeunload
提醒用户写下代码,否则它将永远丢失。该页面还有一个打印按钮,因此用户可以打印凭证。
问题是,在Internet Explorer中,当用户单击链接<a href="javascript:window.print();">
时,会引发事件window.onbeforeunload
。Chrome中不会出现这种情况。
有办法解决这个问题吗?
我已经看到,如果我尝试这个:
<a href="javascript:alert('herp');window.print();">
"herp"消息出现在window.onbeforeunload
显示的警告之后,所以我不知道如何解决此问题。
只需使用<a onclick="window.print();">
而不是href
属性。
相关文章:
- 正在寻找比$(document).ready慢的$(window).load的替代方案
- window.navigate仅适用于Internet Explorer
- Internet Explorer 8, 9 window.open issue
- window.innerWidth 不适用于 Internet Explorer Windows Mobile
- Window.location 在 Internet Explorer 中不起作用
- Internet Explorer 中的 Window.screen 和多个监视器
- JavaScript window.print() Internet Explorer 8 不打印整个网页
- Window.Open()正在更改Internet Explorer上的页面布局
- Internet explorer window.resize在使用document.write后失败
- 当以管理员身份运行Internet Explorer 11时,不同的window.open(..)行为
- 在Internet Explorer中设置window.open()的HTML会产生奇怪的样式问题
- Internet Explorer渲染问题(简单的JS定时器- window.setTimeout)
- Internet Explorer - javascript “apply” 函数在 window.external e
- window.onbeforeunload vs window.print in Internet Explorer
- internet explorer 6-我可以使用javascript's window.open()函数
- JavaScript, window.open, clean url's and Internet Explor
- Internet Explorer 10: $(window).加载不等待自定义字体
- internet explorer - IE javascript location, window.open
- Internet Explorer不处理使用window.open打开的窗口引发的任何事件
- 无法在 Internet Explorer 中为 window.event(或数据属性)分配属性