ドメイン/URLを取得するには
<html>
<head>
<title>Sample</title>
</head>
<body>
ドメインを表示します。<br><br>
<script type="text/javascript"><!--
dn = document.domain;
url = location.href;
document.write("ドメイン:"+dn+"<br>");
document.write("URL:"+url);
// --></script>
</body>
</html>

説明などは本書を参考にしてください。