이상적인 해결책은 존재하지 않는 : 당신이 그것을 어떻게하려고하는 경우
불행하게도, 크로스 브라우저 솔루션이 존재하지 않습니다 HTML 자체. 그러나 대부분의 IE 버전에서 작동합니다. 그러한처럼 : 그래서 최선의 해결책
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="includes/myIEGeneralStyle.css" />
<![endif]-->
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="includes/myIE6Style.css" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="includes/myIE7Style.css" />
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="includes/myIE8Style.css" />
<![endif]-->
:
방법 등과 같은 자바 스크립트 솔루션에 대해 : Browser Detection. 더 명확히하기 위해이 클래스에 대해 조금 읽기, 무엇을 해당 파일이 기본적으로하고있는 것은 같은처럼 단순히 개념이다 :
var browser = navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ? 'chrome' : 'other';
을 분명히, 그냥 브라우저의 종류를 감지보다 더 많은 작업을 수행합니다. 실제로, 그것은 버전, OS, 그리고 당신이 그 링크에서 읽을 수있는 더 많은 세부 사항을 알고 있습니다. 하지만, 'Chrome'을 'mozilla', 'explorer'등으로 바꾸어 모든 브라우저 유형을 확인합니다 ...
그런 다음 CSS 파일을 추가하려면 다음과 같은 조건문을 따르십시오. :
if (BrowserDetect.browser.indexOf("chrome")>-1) {
document.write('<'+'link rel="stylesheet" href="../component/chromeCSSStyles.css" />');
} else if (BrowserDetect.browser.indexOf("mozilla")>-1) {
document.write('<'+'link rel="stylesheet" href="../component/mozillaStyles.css" />');
} else if (BrowserDetect.browser.indexOf("explorer")>-1) {
document.write('<'+'link rel="stylesheet" href="../component/explorerStyles.css" />');
}
행운과 희망이 도움이됩니다!
더블 포스트 ... 각각의 특정 스타일 시트를 제공하기위한 당신이 무슨 이유 http://stackoverflow.com/a/2644080/1100536 – bluejamesbond
을 참조하시기 바랍니다 그 브라우저? – cimmanon