用户单击“停止加载”按钮时发生的任何javascript事件? [英] Any javascript event occurring when user clicks Stop load button?

查看:144
本文介绍了用户单击“停止加载”按钮时发生的任何javascript事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击停止加载按钮(大多数浏览器中为红色X)或按键盘上的Esc时,我想运行一些Javascript,这通常也是如此。

I want to run some Javascript when the user clicks the Stop Load-button (red X in most browsers) or hit Esc on the keyboard, which usually does the same.

我通过挂钩 document.body.onkeyup 看到了覆盖Esc按钮的问题,但找不到任何有关鼠标点击停止按钮的内容。

I've seen questions here covering the Esc button by hooking onto document.body.onkeyup, but couldn't find anything covering mouse click on the Stop button.

推荐答案

Internet Explorer有一个 document.onstop 被触发的事件,但其他浏览器似乎不支持这一点。请注意,当用户单击停止或点击Esc时会触发它,或者如果用户在页面加载期间导航到另一个页面,则会触发,这会产生相同的效果。

Internet Explorer has a document.onstop event that is fired, but other browsers don't seem to support that. Note that it's fired when the user clicks Stop or hits Esc, OR if the user navigates to another page during page load, which has the same effect.

我不知道相信有一种可靠的方法可以在其他浏览器中单击停止时触发事件。也许可以这样做:保持与服务器的连接打开(如) Comet 方法),在连接上流式传输某种保持活动状态,并检测流是否结束(如果单击停止按钮,我认为是这样)。

I don't believe there is a reliable way to trigger an event on clicking Stop in other browsers. Perhaps it would be possible to do something like: keeping the connection to the server open (as in the Comet approach), streaming some sort of keep-alive down the connection, and detecting if the stream ends (as I assume it would if the Stop button were clicked).

这篇关于用户单击“停止加载”按钮时发生的任何javascript事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆