NS_BINDING_ABORTED Javascript window.location.replace() [英] NS_BINDING_ABORTED Javascript window.location.replace()
问题描述
我正在编写一些Javascript代码,我正在尝试更改当前页面,因为用户单击按钮的结果。我正在使用这段代码:
I'm writing some Javascript code and I'm trying to change the current page as the result of the user clicking a button. I'm using this snippet of code:
window.location.replace(/ customer / order / 12);
window.location.replace("/customer/order/12");
包含我想要导航到的网站中的相对URL。当这段代码运行时(在Firebug中查看),url字符串看起来是正确的,但页面只是刷新它当前的内容。用HttpFox查看标题,我看到的第一件事是(Aborted),Type:NS_BINDING_ABORTED。但是,如果我发出此命令:
containing the relative URL within my site that I want to navigate to. When this code runs (looking at it in Firebug), the url string looks correct, but the page just does a refresh to what it's currently on. Looking at the headers with HttpFox the first thing I see is a result of (Aborted), Type: NS_BINDING_ABORTED. However, if I issue this command:
window.location.replace(/ customer / order / 12);
window.location.replace("/customer/order/12");
来自Firebug,浏览器转到我指定的正确网址(/ customer / order / 12)。
from Firebug, the browser goes to the correct url that I specified ("/customer/order/12").
任何人都可以帮我确定这里出了什么问题吗?
Can anyone help me determine what's going wrong here?
提前致谢!
Doug
Thanks in advance! Doug
推荐答案
加载时可能会获得 NS_BINDING_ABORTED
被其他东西打断,通常是页面导航。
You may get NS_BINDING_ABORTED
when a load is interrupted by something else, typically a page navigation.
你是如何调用这种方法的?如果它是对点击链接或按钮的响应,您可能忘记返回false
以取消默认操作。在这种情况下,首先您的脚本将开始导航到 / customer / order / 12
,然后将跟踪链接或表单,从而导致取消脚本的导航。
How are you calling this method? If it's in response to a click on a link or button, you may be forgetting to return false
to cancel the default action. In which case first your script would start to navigate to /customer/order/12
, then the link or form would be followed, causing a navigation that cancels your script's one.
这篇关于NS_BINDING_ABORTED Javascript window.location.replace()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!