+ Reply to Thread
Results 1 to 7 of 7

Thread: Check your IP

  1. #1
    Jaan Guest

    Check your IP

    HTML Code:
    <html>
    <head>
    <script language="JavaScript">
    function disp_ip(){
    var ip = '<!--#echo var="REMOTE_ADDR"-->';
    document.write(ip)
    }
    </script>
    </head>
    <body>
    <form>
    <input type='button' value='Check your Ip' onClick='disp_ip();'>
    </form>
    </body>
    </html>
    But you have to use .shtml extension not .html or .htm because it uses server side includes

  2. CODECALL Circuit advertisement

     
  3. #2
    DevilsCharm's Avatar
    DevilsCharm is offline Programming God
    Join Date
    Jul 2006
    Posts
    884
    Rep Power
    0

    Re: Check your IP

    Always good to have alternatives to ipchicken, ha ha.

  4. #3
    Join Date
    Mar 2008
    Posts
    7,145
    Rep Power
    86

    Re: Check your IP

    Interesting, the only thing is your server has to have SSI enabled for this to work.

    Is their anyway to do this if SSI isn't enabled? I do have SSI enabled but I'm just curious.

  5. #4
    v0id is offline Retired
    Join Date
    Apr 2007
    Posts
    2,937
    Blog Entries
    3
    Rep Power
    42

    Re: Check your IP

    Yes, you'll need to have SSI enabled in order to use the SSI functionality. Most servers does have it as default though, so normally you don't have to mess with it.

  6. #5
    Join Date
    Mar 2008
    Posts
    7,145
    Rep Power
    86

    Re: Check your IP

    My server I needed to enable SSI first but it was possible.

    Though looking at the code, I don't think you need the javascript do you?

    Couldn't you just do this:

    Code:
    <html>
    <head>
    </head>
    <body>
    <!--#echo var="REMOTE_ADDR"-->
    </body>
    </html>
    but on my computer, when testing it, the IP that is displayed is 127.0.0.1 which isn't my IP.

  7. #6
    v0id is offline Retired
    Join Date
    Apr 2007
    Posts
    2,937
    Blog Entries
    3
    Rep Power
    42

    Re: Check your IP

    It's true that you don't need Javascript at all, but the advantage of using Javascript in this situation is that you can save the result in a variable, and eventually use it for various string operations.

    About your IP: If you ran the script locally, it will most likely return localhost (127.0.0.1).

  8. #7
    Join Date
    Mar 2008
    Posts
    7,145
    Rep Power
    86

    Re: Check your IP

    Yeah I guess that is true, you could edit the string without reloading the page, so I guess it is a good idea to use JavaScript here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Check this out!
    By Scott in forum The Lounge
    Replies: 7
    Last Post: 05-09-2010, 10:03 AM
  2. Could someone check this?
    By Alex_j in forum C# Programming
    Replies: 1
    Last Post: 05-05-2010, 12:40 PM
  3. How to check if a check box has changed?
    By Peckerfish in forum C# Programming
    Replies: 2
    Last Post: 05-24-2009, 02:22 PM
  4. Check your IP
    By Jaan in forum PHP Tutorials
    Replies: 7
    Last Post: 01-17-2008, 06:29 AM
  5. Check ISO with CD
    By TcM in forum Computer Software/OS
    Replies: 3
    Last Post: 12-21-2007, 06:20 AM

Tags for this Thread

Bookmarks

Posting Permissions

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