NS_BINDING_ABORTED Javascript window.location.replace()

发布于 2024-08-29 07:22:48 字数 419 浏览 1 评论 0原文

我正在编写一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断肠人 2024-09-05 07:22:48

当加载被其他内容(通常是页面导航)中断时,您可能会收到 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文