Skip to content

Commit e0ef5b3

Browse files
committed
bom特性和客户端检测
1 parent e0853c4 commit e0ef5b3

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>BOM相关操作</title>
5+
<meta charset="utf-8">
6+
<script type="text/javascript">
7+
function clickButton(){
8+
var wroxWin = window.open("http://www.baidu.com","name","height=400,width=400,top=10,left=10,resizable=yes");
9+
10+
}
11+
function clickButton2(){
12+
//location.href = "https://mail.qq.com/cgi-bin/frame_html?sid=A9Qm4HxhCnZad2A4&r=9fb55a1813ce7b55e711e0519b73f2ff";
13+
var argus = getQueryStringArgs();
14+
console.log(argus);
15+
}
16+
function clickButton3(){
17+
alert(hasPlugin("Flash"));
18+
}
19+
function getQueryStringArgs(){
20+
var qs = (location.search.length > 0 ? location.search.substring(1) : "");
21+
var argus = {};
22+
var items = qs.length ? qs.split("&"):[];
23+
var item = null,name=null,value=null,i=0,len = items.length;
24+
for (var i = 0; i < len; i++) {
25+
item = items[i].split("=");
26+
name = decodeURIComponent(item[0]);
27+
value = decodeURIComponent(item[1]);
28+
if (name.length) {
29+
argus[name] = value;
30+
}
31+
}
32+
return argus;
33+
}
34+
function hasPlugin(name){
35+
name = name.toLowerCase();
36+
for(var i=0;i<navigator.plugins.length;i++) {
37+
if (navigator.plugins[i].name.toLowerCase().indexOf(name) > -1) {
38+
return true;
39+
}
40+
}
41+
return false;
42+
}
43+
</script>
44+
<style type="text/css">
45+
</style>
46+
</head>
47+
<body>
48+
<button type="button" onclick="clickButton()" value="其他页面" >其他页面</button>
49+
<button type="button" onclick="clickButton2()">获取location信息</button>
50+
<button type="button" onclick="clickButton3()">检测插件</button>
51+
</body>
52+
</html>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>客户端检测(能力、怪癖、用户代理)</title>
5+
<script type="text/javascript">
6+
7+
function clickButton(argument) {
8+
//确定浏览器是否支持Netscape风格的插件
9+
var hasNSPlugins = !!(navigator.plugins && navigator.plugins.length);
10+
//确定浏览器是否具有DOM1级规定的能力
11+
var hasDOM1 = !!(document.getElementById && document.createElement && document.getElementsByTagName);
12+
alert("hasNSPlugins:" +hasNSPlugins + " hasDOM1:" + hasDOM1);
13+
}
14+
</script>
15+
</head>
16+
<body>
17+
<button type="button" onclick="clickButton()">插件风格和dom1支持检测</button>
18+
</body>
19+
</html>

0 commit comments

Comments
 (0)