这次老大布置了一个任务,但是我有几个地方不会,请大家帮一个忙吧。这个任务主要就是使用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>
这个图片是最终的效果图,主要获取的数据在系统分析里面