如何显示在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
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短