|
-
Jul 27th, 2006, 03:57 AM
#5
Re: Grab IP Address with JavaScript
If you have Server Side Includes (SSI/SHTML) then you can do:
HTML Code:
<script type="text/javascript">
var ip = '<!--#echo var=REMOTE_ADDR -->';
alert('Your IP is ' + ip);
</script>
What happens here is that before the page is sent by the server, the SSI parses the page, finds the #echo statement and replaces the HTML comment with IP address of the client. Thus JavaScript on the client machine is like var ip = '0.0.0.0';
Most often SSI must be enabled separately for .htm and .html pages, this can be done using .htaccess. Or just use .shtml.
Last edited by Merri; Jul 27th, 2006 at 06:51 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|