如何停止页面重定向 [英] how to stop page redirect
本文介绍了如何停止页面重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要通过javascript停止所有页面重定向。
I need to stop all the page redirection through javascript.
我有一些脚本会将页面重定向到其他位置。
如何通过jquery或javascript停止页面上的所有页面重定向。
I have some script which will redirect the page to some other location. How can I stop all the page redirection on my page through jquery or javascript.
推荐答案
您可以停止重定向通过执行以下操作。
You can stop the redirect by doing the following.
<script language="JavaScript" type="text/javascript">
//<![CDATA[
window.onbeforeunload = function(){
return 'Are you sure you want to leave?';
};
//]]>
</script>
不确定是否所有浏览器都支持此功能,但这应该可以解决问题。
Not sure if all browsers support this but that should do the trick.
这篇关于如何停止页面重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文