The domain property

The domain property holds the name of the domain name that served the page to the viewer.
It is everything after http:// and before any other slash.

document.write("You are at " + document.domain + " domain!");

The output is “You are at dan.saigon.ro domain!”.
Be aware that if you use this property locally, not on a real server, the output might be an empty string.

Leave a Reply