Click here to Skip to main content
16,020,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,
I have a little question for u.
My Question is :
How to get Client IP Address from java script.

Please describe each line of code if possible.

Thank you.
Mahesh Patel
Posted
Updated 2-Nov-10 1:43am
v3

Example:
<script type="application/javascript">
    function getip(json){
      alert(json.ip); // alerts the ip address
    }
</script>

<script type="application/javascript" src="http://jsonip.appspot.com/?callback=getip"></script>

Or
<script language="JavaScript">
VIH_BackColor = "palegreen";
VIH_ForeColor = "navy";
VIH_FontPix = "16";
VIH_DisplayFormat = "You are visiting from:<br>IP Address: %%IP%%<br>Host: %%HOST%%";
VIH_DisplayOnPage = "yes";
</br></br></script>
<script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script>

Please vote and Accept Answer if it Helped.
 
Share this answer
 
 
Share this answer
 
v3
Using

JavaScript
var ip = '<!--#echo var="REMOTE_ADDR"-->';


You can have IP Add. of Client.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900