qileilove

          blog已經轉移至github,大家請訪問 http://qaseven.github.io/

          如何在網頁讀取用戶IP,操作系統版本等數據demo

            我們瀏覽網頁的時候,會不經意間看到,有些地方(如個人的簽名檔)顯示出了個人的IP,操作系統等數據.借助第三方API和請求報頭useragent是很容易實現的.
          <html>
          <head>
          <title>Sherry</title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          <script type="text/javascript" src="http://counter.sina.com.cn/ip/" charset="gb2312"></script>
          <script>
          document.writeln("IP地址:"+ILData[0]+"<br />");           //輸出接口數據中的IP地址
          document.writeln("地址類型:"+ILData[1]+"<br />");         //輸出接口數據中的IP地址的類型
          document.writeln("地址類型:"+ILData[2]+"<br />");         //輸出接口數據中的IP地址的省市
          document.writeln("地址類型:"+ILData[3]+"<br />");         //輸出接口數據中的IP地址的
          document.writeln("地址類型:"+ILData[4]+"<br />");         //輸出接口數據中的IP地址的運營商
          //document.write(navigator.userAgent + "<br>");
          document.write("您的操作系統版本為:");
          if(navigator.userAgent.indexOf("Windows NT 6.2") > 0){
          document.write("Windows 8");
          }
          else if(navigator.userAgent.indexOf("Windows NT 6.1") > 0){
          document.write("Windows 7");
          }
          else if(navigator.userAgent.indexOf("Windows NT 6.0") > 0){
          document.write("Windows Vista");
          }
          else if(navigator.userAgent.indexOf("Windows NT 5.2") > 0){
          document.write("Windows 2003");
          }
          else if(navigator.userAgent.indexOf("Windows NT 5.1") > 0){
          document.write("Windows xp");
          }
          else if(navigator.userAgent.indexOf("Windows NT 5.0") > 0){
          document.write("Windows 2000");
          }
          </script>
          </head>
          <body>
          </body>
          </html>
            顯示:

          posted on 2013-10-15 11:20 順其自然EVO 閱讀(472) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2013年10月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 成都市| 兴仁县| 西畴县| 正安县| 崇文区| 资中县| 仁怀市| 武穴市| 拉萨市| 金阳县| 即墨市| 弥渡县| 白朗县| 昌吉市| 东至县| 神农架林区| 财经| 库车县| 麻阳| 枝江市| 宾川县| 南召县| 庄河市| 屏东市| 靖远县| 洪雅县| 连平县| 汝南县| 沁源县| 城口县| 葫芦岛市| 三原县| 姜堰市| 柘城县| 周宁县| 屏南县| 中西区| 酉阳| 克拉玛依市| 句容市| 宿松县|