javascript - current page hostname - sample

<!DOCTYPE html>
<html>
<body>

<p>Display the hostname (and the port if not 80) of the current URL.</p>

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

<script>
document.getElementById("demo").innerHTML =
"Page hostname is: " + window.location.hostname;
</script>

</body>
</html>

Yorumlar