Get URL for dead links in JavaScript

165 views Asked by At

I have a dead link like http://www.tzxabcxyz.com

I am going to that link and Firefox will tell me that "Firefox can't find the server at www.tzxabcxyz.com."

When I use the following code in a bookmarklet: var u = document.URL;

Instead of getting the string "http://www.tzxabcxyz.com", I am getting the string "about:neterror?e=dnsNotFound&u=http%3A//www.tzxabcxyz.com/&c=UTF-8&d=Firefox%20can%27t%20find%20the%20server%20at%20www.tzxabcxyz.com."

My question is how can I get the URL i need instead of the "about:neterror" string?

1

There are 1 answers

0
BearCode On

Found it, "var u = document.location.href;" instead of "var u = document.URL;"

It looks like "document.location.href" doesn't get contaminated with any error in the connection.