Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取JavaScript中死链接的URL_Javascript_Url_Broken Links - Fatal编程技术网

获取JavaScript中死链接的URL

获取JavaScript中死链接的URL,javascript,url,broken-links,Javascript,Url,Broken Links,我有一个像这样的死链接 我将转到该链接,Firefox会告诉我“Firefox在www.tzxabcxyz.com上找不到服务器。” 在bookmarklet中使用以下代码时: var u=document.URL 我得到的不是字符串“”,而是字符串“about:neterror?e=dnsNotFound&u=http%3A//www.tzxabcxyz.com/&c=UTF-8&d=Firefox%20can%27t%20find%20the%20server%20at%20www.tzxa

我有一个像这样的死链接

我将转到该链接,Firefox会告诉我“Firefox在www.tzxabcxyz.com上找不到服务器。”

在bookmarklet中使用以下代码时: var u=document.URL

我得到的不是字符串“”,而是字符串“about:neterror?e=dnsNotFound&u=http%3A//www.tzxabcxyz.com/&c=UTF-8&d=Firefox%20can%27t%20find%20the%20server%20at%20www.tzxabcxyz.com。”

我的问题是如何获得所需的URL而不是“about:neterror”字符串?

找到它时,用“var u=document.location.href;”而不是“var u=document.URL;”


看起来“document.location.href”没有被连接中的任何错误所污染。

在该字符串的末尾<代码>u.slice(0,-1).split(“%20”).pop()