Document domain Property - Javascript DOM

Javascript examples for DOM:Document domain

Description

The domain property returns the server domain name that loaded the document.

Return Value

A String, representing the server domain name that loaded the document. It returns null if the domain of the document cannot be identified

The following code shows how to get the domain name of the server that loaded the document:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">display the domain name of the server that loaded this document</button>

<p id="demo"></p>

<script>
function myFunction() {//  w w  w.j av a  2s .  c  om
    var x = document.domain;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials