hi! can anyone please tell me if there is some code or statement to trace the ip address of visitors using Javascript;
This is a nice easy one to display IP address of users who visit a particular page; http://www.javascriptkit.com/script/script2/displayip.shtml Is this what you are looking for?
You might want to use a server-side language which is easier. Not a function for a JAvascript Like PHP, you would use <?php echo $_SERVER['REMOTE_ADDR']; ?> To trace you might want to add it to a Database.
you can have the user view IP by: <SCRIPT> var ip = new java.net.InetAddress.getLocalHost(); var ipStr = new java.lang.String(ip); document.writeln(ipStr.substring(ipStr.indexOf("/")+1)); </SCRIPT> Although this wont help you track as much, you may store that info in a cookie for the next time they return. As others mentioned, best way is to use one of the many server side programing languages. Good luck...
http://www.ip2location.com/free.asp?ipaddresses=69.63.189.16 -- YOUR IP GOES HERE then use php to gather the info and get the location
JavaScript alone will not give you the IP Address of the visitor, you need a help of server-side scripting.
index.php: <html> <head> <script type="text/javascript" src="get_ip.js.php"></script> </head> <body onload="displayIP();"> <div id="usersIP"></div> </body> </html> Code (markup): get_ip.js.php: function displayIP() { document.getElementById('usersIP').innerHTML = "Your IP is <?php echo $_SERVER['REMOTE_ADDR']?>"; } Code (markup):
this one is what you looking for easyjquery(.)com/detect-get-clients-ip-address-country-using-javascript-php/