我想將JavaScript和CSS應用於所有瀏覽器,但不適用於IE6是否有可能?我想將JavaScript和CSS應用於所有瀏覽器,但不適用於IE6是否有可能?
比如我有一個JavaScript abc.js
我想在所有的瀏覽器IE7,IE8,IE9,火狐,Safari,Chrome瀏覽器使用這個JavaScript。
但我不想在IE6中使用這個JavaScript。
我想將JavaScript和CSS應用於所有瀏覽器,但不適用於IE6是否有可能?我想將JavaScript和CSS應用於所有瀏覽器,但不適用於IE6是否有可能?
比如我有一個JavaScript abc.js
我想在所有的瀏覽器IE7,IE8,IE9,火狐,Safari,Chrome瀏覽器使用這個JavaScript。
但我不想在IE6中使用這個JavaScript。
這應該可以使用組合conditional comments。
你不得不兩次,但另有規定的事情,這應該工作:
<!--[if gt IE 6]>
For Internet Explorer > 6
<![endif]-->
<![if !IE]>
For all other browsers
<![endif]>
這將不會被非IE瀏覽器解析。 – BoltClock 2010-07-19 11:14:55
@BoltClock是的,你是對的。增加了一些解決方案。 – 2010-07-19 11:17:56
@pekka - 兩者都不起作用 – 2010-07-19 13:09:29
可以使用conditional comments通過排除IE 6或更低做的東西。
<![if gt IE 6]>
Markup used by IE 7, 8 and above, and all other browsers ignoring these proprietary tags...
<![endif]>
這就是「Downlevel-revealed Conditional Comments」。
+1這比我的優雅。然而,其他家庭的未來瀏覽器開始支持這些標籤的可能性非常小,在這種情況下,這僅限於IE系列。 – 2010-07-19 11:28:55
Andy Clarke在他的Universal IE6 CSS項目中有答案。我推薦他的'爲一個美麗的網站'的文章,因爲他有一個具體的方法來解決這個問題 - 這可能是也可能不是出於同樣的原因,你希望實現這個唯一的偏愛!
他從通用IE6的CSS代碼:
從Internet Explorer 6隱藏所有其他樣式表,將它們包裝這個條件註釋裏面。
<!--[if ! lte IE 6]><!-->
/* Stylesheets for browsers other than Internet Explorer 6 */
<!--<![endif]-->
然後添加Universal Internet Explorer 6樣式表。
<!--[if lte IE 6]>
<link rel="stylesheet" href="http://universal-ie6-css.googlecode.com/files/ie6.1.1.css" media="screen, projection">
<![endif]-->
請參閱以下完整的文章,以及完整的代碼在它的鏈接: http://forabeautifulweb.com/blog/about/universal_internet_explorer_6_css
感謝它爲我工作 – 2010-07-19 14:28:22
不工作我錯了 – 2010-07-20 06:59:22
supero從Internet Explorer 6隱藏所有其他樣式表,將它們包裝這個條件註釋裏面。
<!--[if ! lte IE 6]><!-->
/* Stylesheets for browsers other than Internet Explorer 6 */
<!--<![endif]-->
然後添加Universal Internet Explorer 6樣式表。
<!--[if lte IE 6]>
<link rel="stylesheet" href="http://universal-ie6-css.googlecode.com/files/ie6.1.1.css" media="screen, projection">
<![endif]-->
你還在支持ie6 :) – JoseK 2010-07-19 11:14:19
@JoseK是的,有些網站還是要。包括我們現在正在使用的那個。 – 2010-07-19 11:14:59
@Pekka其實我們也是 - 所以我不知道我在笑什麼。 – JoseK 2010-07-19 11:16:56