Today I would like to introduce you two JS to get the current domain name
The code is as follows
Get the current domain name
1, Window.location.host;
2, Document.domain;
Get current page address
url = window.location.href;
Example
The code is as follows
<script language= "JavaScript" >
Get Domain Name
host = Window.location.host;
Host2=document.domain;
Get full address of page
url = window.location.href;
document.write ("<br>host=" +host)
document.write ("<br>host2=" +host2)
document.write ("<br>url=" +ur (www.45it.net) L)
</script>
Add:
Get current domain name information
The code is as follows
Thistloc = Top.location.href;
Thisploc = parent.document.location;
Thisthost = Top.location.hostname;
Thishost = Location.hostname;
Strwrite = "Thistloc: [" + Thistloc + "]"
Strwrite + = "Thisploc: [" + Thisploc + "]"
Strwrite + = "Thisthost: [" + Thisthost + "]"
Strwrite + = "Thishost: [" + Thishost + "]"
document.write (Strwrite);