NS_BINDING_ABORTED Javascript window.location.replace()
我正在编写一些 Javascript 代码,并尝试根据用户单击按钮来更改当前页面。我正在使用这段代码:
window.location.replace("/customer/order/12");
包含我想要导航到的网站内的相对 URL。当这段代码运行时(在 Firebug 中查看),url 字符串看起来是正确的,但页面只是刷新了当前的内容。使用 HttpFox 查看标头,我看到的第一件事是(已中止)的结果,类型:NS_BINDING_ABORTED。但是,如果我发出此命令:
window.location.replace("/customer/order/12");
从 Firebug 中,浏览器会转到我指定的正确网址(“/customer/order/12”)。
谁能帮我确定这里出了什么问题?
提前致谢! 道格
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");
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");
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?
Thanks in advance!
Doug
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当加载被其他内容(通常是页面导航)中断时,您可能会收到
NS_BINDING_ABORTED
消息。你如何调用这个方法?如果它是为了响应链接或按钮的点击,您可能会忘记
返回 false
来取消默认操作。在这种情况下,您的脚本首先将开始导航到/customer/order/12
,然后将跟随链接或表单,导致导航取消您的脚本的导航。You may get
NS_BINDING_ABORTED
when a load is interrupted by something else, typically a page navigation.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.