We call it the <script type= "Text/javascript" src= "http://fw.qq.com/ipaddress" ></script>. It can return user IP and address, such as: var ipdata = new Array ("220.181.108.85", "", "Beijing", ""); We can use Ipdata[0] as a user IP.
But recently did not know what is going on Tencent, this address is invalid, prompted "HTTP 500 Internal server error."
Another way for JavaScript to get client IP
Recently, I found another way to get the client IP, the service is provided by a foreign website. Use the following methods:
<script language= "JavaScript" > Vih_backcolor = "Palegreen"; Vih_forecolor = "Navy"; Vih_fontpix = "16"; Vih_displayformat = "You are visiting From:ip address:%%ip%% Host:%%host%%"; Vih_displayonpage = "Yes"; </script> <script language= "JavaScript" src= "http://www.hashemian.com/js/visitorIP.js.php" ></ Script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Your IP is shown below:
You are are visiting from:
IP address:117.87.4.102
host:102.4.87.117.broad.xz.js.dynamic.163data.com.cn
If you do not want to display on the Web page, just want to get IP, for other purposes, then you need to change vih_displayonpage = "Yes" to Vih_displayonpage = "no". The IP variable is vih_hostip. The method is invoked as follows:
<script language= "JavaScript" > vih_displayonpage = "no"; </script> <script language= "JavaScript" src= "http://scripts.hashemian.com/js/visitorIPHOST.js.php" > </script> <script language= "JavaScript" > Alert ("Your IP is:" + vih_hostip); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]