如何用js获取客户端IP地址?  请高手指教

解决方案 »

  1.   

    安全问题,直接获取不到。可以用script加载一个动态提供js语法输出的ip地址的动态页就可以实现了
    <script type="text/javascript" src="http://www.coding123.net/getip.ashx?js=1"></script>
    <script>
    alert(ip)
    </script>
      

  2.   

    什么意思不是很明白?请高手指点   我做了个在线调查 需要获取下参与人员的ip地址 ,用来保证一个ip地址只能提交一次
      

  3.   

    保存到html里试,这个是获取用户IP,打开一次你往数据库写一次IP。以后判断IP存在就不让提交不得了<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN" xml:lang="zh-CN">
    <head>
    <script language="Javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script language="Javascript" type="text/javascript" src="http://api.easyjquery.com/easyjquery.js"></script>
    <title>TYGF</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>
    </body>
    <script>
        GetIP();
         function my_callback2(json) {
            alert(json.IP);
        }
        function GetIP(){
           EasyjQuery_Get_IP("my_callback2","full"); // full version
          } 
    </script>
    </html>
      

  4.   

    直接在后台用request.servervariables("REMOTE_ADDR")多好
      

  5.   

    这个要通过服务器的,你也可以通过ajax去服务器端获取吧。