如何显示在JavaScript中加载文档的服务器的域?
Javascript 提供了文档对象来获取有关文档的任何详细信息。它提供了document.domain来获取在其中加载文档的服务器的域。
示例
在以下示例中,文档被加载到“tutorialspoint”服务器中。因此,我们将获得的域名是“www.tutorialspoint.com”。Document.domain是一个内置函数,用于获取在其中加载文档的服务器的域。在“tutorialspoint” 服务器中使用此方法时,将加载有关“tutorialspoint” 的域,如输出所示。
<html>
<body>
<p id="domain"></p>
<script>
document.getElementById("domain").innerHTML =
'The domain name is :'+" "+document.domain;
</script>
</body>
</html>输出结果
The domain name is www.tutorialspoint.com
热门推荐
9 怎么说祝福语简短
10 虎年台词祝福语大全简短
11 分手毕业祝福语简短女生
12 新春进门祝福语大全简短
13 新年的鸡汤祝福语简短
14 双节祝福语简短唯美
15 长辈生日祝福语简短女性
16 给干爸过年祝福语简短
17 祝老婆生日祝福语简短
18 六一祝福语简短感动女生