js怎麼擷取訪問頁數記錄(知道的能不能告訴我一下)

來源:互聯網
上載者:User

標籤:border   作業系統   解析度   網站   記錄   

這次老大布置了一個任務,但是我有幾個地方不會,請大家幫一個忙吧。這個任務主要就是使用js擷取:1.網站來源截取2.上網IP截取3.上網地址截取4.作業系統截取5.解析度截取6.訪問頁數記錄,但是我只能擷取到1.網站來源4.作業系統5.解析度這幾個,其中上網IP、地址我是截取到,但是有人說我這種截法是不行的,所以你們誰看到的能不能告訴我一下這幾個是怎樣截取的,謝謝你們了,這個是我寫的代碼,能不能告訴我一下那個文字效果是什麼啊


<!DOCTYPE HTML>

<html>

<head>

<meta charset="UTF-8">

<title>目前使用者訪問資訊</title>

<script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>

<style type="text/css"> 

.mains{width:400px;height:300px;border:1px solid #333;margin-left:60px;margin-top:60px;font-size:14px;padding:10px;}

.guanjian{width:30%;height:30px;float:left;}

.huoqu{width:70%;height:30px;float:left;}

</style>

</head>

<body>

<div class="mains">

<h1>系統分析</h1>

<div><div class="first">初次來源:</div><div class="huoqu laiyuan"></div></div>

<div><div class="guanjian">搜尋關鍵詞:</div><div class="huoqu word"></div></div>

<div><div class="guanjian">上網IP:</div><div class="huoqu ip">

<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>  

<script type="text/javascript">  document.write(returnCitySN["cip"])  </script>

</div></div>

<div><div class="guanjian">上網地址:</div><div class="huoqu">

<script type="text/javascript">  document.write(returnCitySN["cname"])  </script>

</div></div>

<div><div class="guanjian">作業系統:</div><div class="huoqu xitong"></div></div>

<div><div class="guanjian">解析度:</div><div class="huoqu fenbianlv"></div></div>

<div><div class="guanjian">訪問頁數:</div><div class="huoqu"></div></div>

</div>


<script type="text/javascript"> 

//擷取初次來源

$ly=document.write(document.referrer);

$(".laiyuan").text($ly);


//擷取搜尋關鍵詞

function GetQueryString($name){

    var $index=document.referrer.indexOf($name+"="),$e=‘‘;

    if($index>1){

        $e=document.referrer.substring($index+$name.length+1);

        if(($index=$e.indexOf("&"))>0){

            $e=$e.substring(0,$index);

        }

    }

    return $e;

}

$wd=GetQueryString("wd");

if($wd&&$wd.length>0){

    $wd=decodeURIComponent($wd);}

$(".word").text($wd);

//擷取上網IP




//擷取上網地址

//擷取作業系統

function detectOS() {

    var sUserAgent = navigator.userAgent;

    var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");

    var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");

    if (isMac) return "Mac";

    var isUnix = (navigator.platform == "X11") && !isWin && !isMac;

    if (isUnix) return "Unix";

    var isLinux = (String(navigator.platform).indexOf("Linux") > -1);

    if (isLinux) return "Linux";

    if (isWin) {

        var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;

        if (isWin2K) return "Win2000";

        var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;

        if (isWinXP) return "WinXP";

        var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1;

        if (isWin2003) return "Win2003";

        var isWinVista= sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1;

        if (isWinVista) return "WinVista";

        var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1;

        if (isWin7) return "Win7";

    }

    return "other";

}

$xt=detectOS();

$(".xitong").text($xt);

//擷取解析度

$fbl_1=screen.width;

$fbl_2=screen.height;

$fbl=$fbl_1+"*"+$fbl_2;

$(".fenbianlv").text($fbl);

//擷取訪問頁數


</script>

</body>

</html>

這個圖片是最終的,主要擷取的資料在系統分析裡面650) this.width=650;" src="http://s1.51cto.com/wyfs02/M02/89/29/wKioL1gJxurj4QgIAAjqF6qWiNE438.gif-wh_500x0-wm_3-wmp_4-s_2462290981.gif" title=".gif" alt="wKioL1gJxurj4QgIAAjqF6qWiNE438.gif-wh_50" />

本文出自 “前端” 部落格,請務必保留此出處http://xhlsky.blog.51cto.com/9087386/1864319

js怎麼擷取訪問頁數記錄(知道的能不能告訴我一下)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.