获取JavaScript中死链接的URL

Get URL for dead links in JavaScript

本文关键字:URL 链接 JavaScript 获取      更新时间:2023-09-26

我有一个死链接http://www.tzxabcxyz.com

我要去那个链接,Firefox会告诉我"Firefox在www.tzxabcxyz.com上找不到服务器。"

当我在bookmarklet中使用以下代码时:var u=文档。URL;

而不是获取字符串"http://www.tzxabcxyz.com",我正在获取字符串"about:neterror?e=dnsNotFound&u=http://www.tzxabcxyz.com/&c=UTF-8&d=Firefox%20可以%27t%20在%20www.tzxabcxyz.com上查找%20服务器%20。"

我的问题是如何获得我需要的URL,而不是"about:neterror"字符串?

找到它,"var u=document.location.href;"而不是"var u=document.URL;"

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