JS根据不同浏览器加载不同css或JS
<script> function getBrowser() { var ua = window.navigator.userAgent; var isIE = ua.indexOf("MSIE") != -1 || ua.indexOf("Trident") != -1; var isIEEdge = ua.indexOf("Edge") != -1; var isFirefox = ua.indexOf("Firefox") != -1; var isOpera = window.opr != undefined; var isChrome = ua.indexOf("Chrome") && window.chrome; var isSafari = ua.indexOf("Safari") != -1 && ua.indexOf("Version") != -1; if(isIE) { return "IE"; } else if(isIEEdge) { return "Edge"; } else if(isFirefox) { return "Firefox"; } else if(isOpera) { return "Opera"; } else if(isChrome) { return "Chrome"; } else if(isSafari) { return "Safari"; } else { return "Unkown"; } } var linkNode = document.createElement("link"); linkNode.setAttribute("rel", "stylesheet"); linkNode.setAttribute("type", "text/css"); if(getBrowser() == "IE" || getBrowser() == "Edge") { linkNode.setAttribute("href", "css/_edge.css"); } else if(getBrowser() == "Safari") { linkNode.setAttribute("href", "css/_safari.css"); } else { linkNode.setAttribute("href", "css/_chromeFF.css"); } document.head.appendChild(linkNode); </script>
略懂,略懂....