我希望你能幫助我。 我需要爲每個瀏覽器加載一個css(chorme,safari,mozilla,ie)。 我發現了一個解決方案,我添加了safari選項,但仍然無法使用。爲每個瀏覽器加載CSS
<script type="text/javascript">
var browser = navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ? 'chrome' : 'other';
if (BrowserDetect.browser.indexOf("chrome")>-1) {
document.write('<'+'link rel="stylesheet" href="/css/chrome.css" />');
} else if (BrowserDetect.browser.indexOf("mozilla")>-1) {
document.write('<'+'link rel="stylesheet" href="css/mozilla.css" />');
} else if (BrowserDetect.browser.indexOf("explorer")>-1) {
document.write('<'+'link rel="stylesheet" href="css/explorer.css" />');
} else if (BrowserDetect.browser.indexOf("safari")>-1) {
document.write('<'+'link rel="stylesheet" href="css/safari.css" />');
}
</script>
在頁面上有一個HTML5音頻播放器,在每個瀏覽器中,這個播放器會改變顏色,所以它們必須每個都不相同。
你的情況下,你的意思是它的工作原理與Safari瀏覽器以外的所有瀏覽器? – SaidbakR
[如何檢測Safari,Chrome,IE,Firefox和Opera瀏覽器?](https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera瀏覽器) – ThePHPAddicted