[英]Stop navigation AFTER link has been clicked
preventDefault()
here) preventDefault()
) preventDefault()
) preventDefault()
) Now, when I click on another inactive link after an active link is clicked, the browser will still got to the active link's url. 现在,当我单击一个活动链接后单击另一个非活动链接时,浏览器仍会转到该活动链接的URL。
So the question is: How can I abort/stop/cancel a link navigation, after the link was pressed? 因此,问题是:在按下链接后 ,如何中止/停止/取消链接导航? IE my browser is already working.
IE浏览器已经可以使用了。
The question is not : How can I prevent the link to be followed, if I click on the link? 问题不在于:如果单击链接,如何防止链接被跟踪?
jQuery('a.button').on('click', function(e){
if ( jQuery(this).hasClass('active') ) {
// no preventDefault(), so link is followed
return;
}
e.preventDefault();
// how can I stop the link from above?
// ..
jQuery(this).addClass('active')
// do the slide thing
});
Sounds like what you're trying to do is window.stop()
. 听起来您想要做的是
window.stop()
。
https://developer.mozilla.org/en-US/docs/Web/API/Window/stop https://developer.mozilla.org/zh-CN/docs/Web/API/Window/stop
The stop() method is exactly equivalent to clicking the stop button in the browser.
stop()方法与单击浏览器中的停止按钮完全等效。 Because of the order in which scripts are loaded, the stop() method cannot stop the document in which it is contained from loading, but it will stop the loading of large images, new windows, and other objects whose loading is deferred.
由于脚本的加载顺序,stop()方法无法停止包含该脚本的文档的加载,但是它将停止加载大图像,新窗口以及其他推迟加载的对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.