当页面加载失败时,在Chrome中获取当前域名 [英] Getting the current domain name in Chrome when the page fails to load

查看:1015
本文介绍了当页面加载失败时,在Chrome中获取当前域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您尝试使用Chrome加载: http://sdqdsqdqsdsqdsqd.com/

If you try to load with Chrome: http://sdqdsqdqsdsqdsqd.com/

您将获得:

You'll obtain:

ERR_NAME_NOT_RESOLVED

我希望通过一个bookmarklet获取当前的域名并将其重定向到一个whois页面以检查域是否可用。

I would like, with a bookmarklet, to be able to get the current domain name and redirect it to a whois page in order to check if the domain is available.

我在控制台中试过:

I tried in the console:

window.location.href

但输出:

but it outputs:

"data:text/html,chromewebdata"

有没有办法检索失败的URL?

Is there any way to retrieve the failed URL?

推荐答案

在Chrome错误页面上, location.href 并不指向您试图访问的域名,因为它是一个内部托管的页面。

On the Chrome error page, location.href doesn't point to the domain you tried to visit, since it's an internally-hosted page.

但是,您试图访问的域名是可用的if您展开显示详情链接。

However, the domain name you tried to visit is available if you expand the "Show Details" link.

呦您可以在控制台(或书签)中运行此代码来解析出域名:

You can run this code in console (or a bookmarklet) to parse out the domain name:

document.querySelector('strong[jscontent="hostName"]').textContent

这篇关于当页面加载失败时,在Chrome中获取当前域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆