Is there a way to obtain the domain name of the current page by using javascript in a browser (IE, FireFox, etc) ?
Asked
Active
Viewed 1e+01k times
78
-
which windows machine? The client or the server? – ftrotter Aug 19 '12 at 22:31
3 Answers
141
If you are asking about the machine name of the host that served up the current page, you can find that with
window.location.hostname
If you are asking about the name of the machine that is displaying the page in a browser, that information is restricted by browsers for security purposes.

Mike Clark
- 11,769
- 6
- 39
- 43
19
13
window.location.host
EDIT: If you meant the domain of the client machine, I don't think it is possible.

Chetan S
- 23,637
- 2
- 63
- 78
-
2except on ie, which have something i would rather not to say..... active....x. – J-16 SDiZ May 13 '12 at 16:55