Advertisement
KodingKid

How to display a page url and host website using Javascript

Apr 21st, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.getElementById("demo").innerHTML =
  2. "Page URL is " + window.location.href;
  3. //page location (example: https://pastebin.com/TqEhPaiC)
  4. document.getElementById("demo").innerHTML =
  5. "Page website is " + window.location.hostname;
  6. //page hostname (example: pastebin.com)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement