Javascript DOM HTML Document domain Property get

Introduction

Get the domain name of the server that loaded the document:

var x = document.domain;

Click the button to display the domain name of the server that loaded this document.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//from w  w w .j  a v  a  2 s.co  m
  var x = document.domain;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

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

The domain property returns null if the domain of the document cannot be identified




PreviousNext

Related