下面的例子可得到当前文档的域名:
<html>
<body>
<p>当前文档域名为
<script type=
"text/javascript"
>
document.write(document.domain)
</script>
</p>
</body>
</html>
运行该例子输出:当前文档域名为 www.520mg.com