But you have to use .shtml extension not .html or .htm because it uses server side includesHTML 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>![]()
Always good to have alternatives to ipchicken, ha ha.
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.
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.
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:
but on my computer, when testing it, the IP that is displayed is 127.0.0.1 which isn't my IP.Code:<html> <head> </head> <body> <!--#echo var="REMOTE_ADDR"--> </body> </html>![]()
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).
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks