标签:c style class blog code java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 |
<!DOCTYPE html> <head> <meta http-equiv= "Content-Type"
content= "text/html; charset=utf-8"
/> <title></title> <style type= "text/css" ></style> <script type= "text/javascript" > window.onload = function
() { var
oUl = document.getElementById( "ul1" ); if
(oUl.firstElementChild) { //谷歌浏览器 oUl.firstElementChild.style.background = "red" ; } if
(oUl.firstChild) { //IE 浏览器 oUl.firstChild.style.background = "red" ; } } </script> </head> <body> <ul id= "ul1" > <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </body> </html> |
IE 有firstChild所以是true,相反的,谷歌没有,会返回undifined
Javascript 中判断是谷歌浏览器和IE浏览器的方法,布布扣,bubuko.com
标签:c style class blog code java
原文地址:http://www.cnblogs.com/alphafly/p/3763873.html