"SERVER_NAME" javascript

"SERVER_NAME" javascript
Probably what you’re after is the host attribute of the location object. Try this–
<script type="text/javascript"><!--
  document.write( "This server is: " +
                   document.location.host );
//-->
</script>
Which should result in–
NB: if the port is part of the document’s URI it will also show up. You can get around that, assuming you care to try, with something like–
document.location.host.replace(/:\d+$/,'');
More keywords for this post: host name, hostname, server name, $ENV{SERVER_NAME}, env.server_name.
[close] Permanent link · http://querylog.com/q/%22SERVER_NAME%22+javascript

Suggested HTML for linking:
Link preview: "SERVER_NAME" javascript
14 October 2005 · Internet & computing
The page found by the original query:
Code snippets in Perl and JavaScript
Browse by the page—15 Q&R each
« previous | more »