1 /**
2 * 判断用的是那个浏览器,操作系统,浏览器使用的内核
3 */
4 (function() {
5 var ua = navigator.userAgent || "";
6 YJ.browser = "";
7 if (document.recalc || document.documentMode) {
8 YJ.browser = "ie";
9 }
10 if (window.XULElement || ua.match("Gecko")) {
11 YJ.browser = "gecko";
12 }
13 if (window.opera) {
14 YJ.browser = "opera";
15 opera.setOverrideHistoryNavigationMode('compatible');
16 history.navigationMode = 'compatible';
17 }
18 if (ua.match("WebKit")) {
19 YJ.browser = "webkit";
20 }
21 if (ua.match("Konqueror")) {
22 YJ.browser = "konqueror";
23 }
24 if (YJ.browser) {
25 YJ[YJ.browser] = true;
26 }
27 if (YJ.webkit) {
28 if (ua.match("Chrome")) {
29 YJ.chrome = true;
30 var rwebkit = /(chrome)[ \/]([\w]+)/i;
31 var match = rwebkit.exec(ua);
32 YJ.chromeVersion = match[2];
33 } else if (ua.match("Safari")) {
34 YJ.safari = true;
35 }
36 }
37 if ("ontouchstart" in window || navigator.msMaxTouchPoints > 0) {
38 YJ.touch = true
39 }
40 if (ua.match(/iPhone|iPad|iPod|Android/)) {
41 YJ.mobile = true
42 }
43 if (YJ.safari && !document.eva luate) {
44 YJ.safari2 = true;
45 }
46 if (ua.match("Mac OS")) {
47 YJ.mac = true
48 }
49 if (!ua.match("Windows")) {
50 YJ.unix = true;
51 }
52 YJ.theme = "classic";
53 if (ua.match("Windows NT 6")) {
54 YJ.theme = "vista";
55 }
56 if (ua.match("Windows NT 5.1")) {
57 YJ.theme = "xp";
58 }
59 if (ua.match("Mac OS") || ua.match("Android")) {
60 YJ.theme = "aqua";
61 }
62
63 YJ.strict = ("" + document.compatMode).match("CSS");
64 if (YJ.safari2 || (YJ.safari && !document.compatMode && document.doctype && (document.doctype.systemId || !("" + document.doctype.publicId).match(/(Transitional|Final)/)))) {
65 YJ.strict = true;
66 }
67 if (!YJ.strict) {
68 YJ.quirks = true;
69 }
70 var htmlc = " yj-all";
71 if (YJ.strict) {
72 htmlc += " yj-strict";
73 }
74 if (YJ.quirks) {
75 htmlc += " yj-quirks";
76 }
77 if (YJ.browser) {
78 htmlc += " yj-" + YJ.browser;
79 }
80 if (YJ.safari) {
81 htmlc += " yj-safari";
82 }
83 if (YJ.chrome) {
84 htmlc += " yj-chrome";
85 }
86 if (YJ.touch) {
87 htmlc += " yj-touch"
88 }
89 if (YJ.mobile) {
90 htmlc += " yj-mobile"
91 }
92 if (YJ.unix) {
93 htmlc += " yj-unix";
94 }
95 if (YJ.theme) {
96 htmlc += " yj-" + YJ.theme;
97 }
98 if (YJ.theme && YJ.strict) {
99 htmlc += " yj-" + YJ.theme + "-strict";
100 }
101 if (YJ.ie) {
102 var s = document.documentElement.currentStyle;
103 if (ua.match("MSIE 11")) {
104 YJ.ie11 = true;
105 htmlc += " yj-ie11"
106 }else if (ua.match("MSIE 10")) {
107 YJ.ie10 = true;
108 htmlc += " yj-ie10"
109 } else if (ua.match("MSIE 9")) {
110 YJ.ie9 = true;
111 htmlc += " yj-ie9"
112 } else if (s.outlineStyle) {
113 YJ.ie8 = true;
114 htmlc += " yj-ie8";
115 } else if (s.maxWidth) {
116 YJ.ie7 = true;
117 htmlc += " yj-ie7";
118 } else if (s.textOverflow) {
119 YJ.ie6 = true;
120 htmlc += " yj-ie6";
121 } else if (s.writingM