Results 1 to 9 of 9

Thread: Grab IP Address with JavaScript

Threaded View

  1. #5
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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
  •  



Click Here to Expand Forum to Full Width