判断设备是否为手机1234567891011//判断设备是否为手机var ua = navigator.userAgent;var ipad = ua.match(/(iPad).*OS\s([\d_]+)/), isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/), isAndroid = ua.match(/(Android)\s+([\d.]+)/), isMobile = isIphone || isAndroid;if (isMobile) { include_css("test1.css");} else { include_css("test2.css");} 网页 js 加载 css 样式表123456789101112131415161718192021// 网页js加载css样式表var css;function include_css(css_file) { var html_doc = document.getElementsByTagName("head")[0]; css = document.createElement("link"); css.setAttribute("rel", "stylesheet"); css.setAttribute("type", "text/css"); css.setAttribute("href", css_file); html_doc.appendChild(css); // alert state change css.onreadystatechange = function () { if (css.readyState == "complete") { console.log("CSS onreadystatechange fired"); } }; css.onload = function () { console.log("CSS onload fired"); }; return false;}