gpt4 book ai didi

javascript - 调用 document.location.replace() 时 FF 中的 NS_ERROR_MALFORMED_URI

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:29:08 24 4
gpt4 key购买 nike

我在 FF 3.5.6 中看到以下异常:

uncaught exception: [Exception... "The URI is malformed"  nsresult: "0x804b000a (NS_ERROR_MALFORMED_URI)"  location: "JS frame :: http://x :: refreshPage :: line 193"  data: no]

在 iframe 的父窗口上调用 document.location.replace("/relative/url") 时会发生此错误。

它在 FF2 中也可重现,但 IE8 没有出现该问题。

编辑:相同上下文中的以下代码没有问题:

document.location.reload();

最佳答案

为此,我想到的解决方案是编写一个绝对 URL 并将其分配给 window.location。 Reload() 导致内部重定向出现一些问题。

function get_full_url(url_path)
{
var loc = window.location;
var url = "" + loc.protocol + "//" + loc.host + url_path;
return url;
}

function refresh_page_absolute(url_path)
{
window.location.href = get_full_url(url_path)
}

关于javascript - 调用 document.location.replace() 时 FF 中的 NS_ERROR_MALFORMED_URI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1925460/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com