www.webdeveloper.com
Results 1 to 7 of 7

Thread: show my users ip address on my site

  1. #1
    Join Date
    Dec 2005
    Posts
    33

    show my users ip address on my site

    does anyone know how to show my users ip address on my site?
    in html code, cheers

  2. #2
    Join Date
    Jul 2006
    Posts
    60
    I think the easiest way to do this without going into server side scripting in say PHP, is to use a bit of javascript... eg.

    [CODE]
    <script type="text/javascript">
    var ipAddress = '<!--#echo var="REMOTE_ADDR"-->';
    alert (ipAddress);
    </script>

    Someone else may have a better way tho!

  3. #3
    Join Date
    Dec 2005
    Posts
    33
    thanks slolearner but it does not work, im not using server tech on the site im working on just basic html pages

  4. #4
    Join Date
    Jan 2007
    Posts
    16
    There's no way (is it?!) to show the IP using basic html.

  5. #5
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    Quote Originally Posted by sloLearner
    I think the easiest way to do this without going into server side scripting in say PHP, is to use a bit of javascript... eg.

    [CODE]
    <script type="text/javascript">
    var ipAddress = '<!--#echo var="REMOTE_ADDR"-->';
    alert (ipAddress);
    </script>

    Someone else may have a better way tho!

    That doesn't need the Javascript portion to work but it does need Server Side Includes (SSI) to be turned on in order to work in which case <!--#echo var="REMOTE_ADDR"--> will display the IP address at whatever point you include it in the HTML (provided your filename ends in .shtml).

    There is no way to get your visitor's IP address without server side processing because HTML, CSS, Javascript etc that run in the client have no access to anything outside the page and can't see the IP address unless a server side process gives it to them.

    To get the IP address you need SSI, PHP, ASP, or some other server side language to extract it for you and then give your page the appropriate extension so that the server side language will be run on the page before it is delivered to the browser.
    Stephen

  6. #6
    Join Date
    Jan 2008
    Posts
    4

    Exclamation Doesn't work

    The script at: http://javascript.internet.com/user-...p-address.html works THERE,
    but the script offered doesn't work when copied.
    The pop-up displays: /!\ Your IP address is <!--#echo var="REMOTE_ADDR"-->
    The source code has my IP address INSTEAD of the generating echo code!
    not HOW it was fetched.

    var ipAddress = <!--#echo var="REMOTE_ADDR" -->;
    returns: /!\ Your IP address is undefined Getting closer...
    I have tried this script mounted on a web page, not just on my computer.
    How do I 'define' the the IP address or "REMOTE_ADDR" ?
    Can someone correct this? what is the complete correct code?
    using Firefox 2.0 or Seamonkey1.1, SUSE Linux.

  7. #7
    Join Date
    Feb 2013
    Posts
    3
    Quote Originally Posted by se4no View Post
    does anyone know how to show my users ip address on my site?
    in html code, cheers
    You can use the Code:
    Code:
    <div style="width:600px; overflow:hidden;"><table cellpadding="0" cellspacing="0" border="0">
    <tr><td><iframe src="http://www.ip-details.com/ip-details-client/api/?mode=1&cdx=%5bdiv+style%3d%22border%3a2px+solid+gray%3b+background-color%3a%23efefef%3b+color%3ablack%3b+width%3a600px%3b+height%3a25px%3b+font-size%3a14px%3b+overflow%3ahidden%3b+padding-top%3a3px%3b+padding-left%3a5px%3b%22%5d%5bspan+style%3d%22color%3a%23333333%3b%22%5d%5bb%5dYour+IP+Address+%5b%2fb%5d%5b%2fspan%5d%3a+%5bip%5d%2c+%5bcountry%5d%2c+%5bisp%5d%5b%2fdiv%5d" frameborder="0" height="25px" width="600px" scrolling="no"></iframe></td></tr>
    <tr><td style="font-size:x-small;" align="right">Powered by <a href="http://www.ip-details.com/">IP-Details.com</a></td></tr></table></div>
    I got it from IP-Details.com .Visit the site and customize the code that suites you.

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles