如何显示在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 婚前女儿生日祝福语简短