Get current domain name in javascript

In javascript the window.location object can be used to get the current domain name.

[code language=”javascript”]
<script>
alert("current domain is " + window.location.hostname)
</script>
[/code]