Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

- - - - -

Check your IP


  • Please log in to reply
6 replies to this topic

#1 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 28 October 2007 - 09:34 PM

<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 :)
  • 0

#2 DevilsCharm

DevilsCharm

    Programming God

  • Just Joined
  • PipPipPipPipPipPip
  • 858 posts

Posted 18 May 2008 - 04:10 PM

Always good to have alternatives to ipchicken, ha ha.
  • 0

#3 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 28 May 2008 - 02:26 AM

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.
  • 0

#4 v0id

v0id

    Retired

  • Retired Mod
  • PipPipPipPipPipPipPipPip
  • 2313 posts

Posted 28 May 2008 - 03:19 AM

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.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#5 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 28 May 2008 - 03:26 AM

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:

<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. :o
  • 0

#6 v0id

v0id

    Retired

  • Retired Mod
  • PipPipPipPipPipPipPipPip
  • 2313 posts

Posted 28 May 2008 - 03:32 AM

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).
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#7 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 28 May 2008 - 12:10 PM

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.
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download