[英]How to stop page from redirecting without event in Javascript or jQuery?
I have an ajax plugin with a load of ajax files from a tag.我有一个 ajax 插件,其中包含来自标签的大量 ajax 文件。 When user clicks on it I don't see it to redirecting to the other page.
当用户点击它时,我没有看到它重定向到另一个页面。 Although we stop redirecting page using events like:
尽管我们停止使用以下事件重定向页面:
$(button).click(function (e) {
e.preventDefault();
})
I want a function that stop page from redirecting without events.我想要一个阻止页面在没有事件的情况下重定向的功能。
function functionName() {
functiontostopredirect(); // I need a function like this.
}
You can return false
from that function:您可以从该函数
return false
:
function functionName() {
return functiontostopredirect(); // i need a function like this.
}
functiontostopredirect(){ return false;}
添加 return false ,onclick 按钮:
<button type="submit" onclick="return false;">Submit</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.