我想将javascript和CSS应用于所有浏览器,但不应用于IE6。有可能吗?
我想将javascript和CSS应用于所有浏览器,但不应用于IE6。有可能吗 例如,我有一个javascript abc.js 我想在所有浏览器IE7、IE8、IE9、Firefox、Safari和Chrome中使用此javascript我想将javascript和CSS应用于所有浏览器,但不应用于IE6。有可能吗?,javascript,css,Javascript,Css,我想将javascript和CSS应用于所有浏览器,但不应用于IE6。有可能吗 例如,我有一个javascript abc.js 我想在所有浏览器IE7、IE8、IE9、Firefox、Safari和Chrome中使用此javascript 但我不想在IE6中使用此javascript。这应该可以使用以下组合 您必须指定两次,否则,这将起作用: <!--[if gt IE 6]> For Internet Explorer > 6 <![endif]-->
但我不想在IE6中使用此javascript。这应该可以使用以下组合 您必须指定两次,否则,这将起作用:
<!--[if gt IE 6]>
For Internet Explorer > 6
<![endif]-->
<![if !IE]>
For all other browsers
<![endif]>
你可以通过排除IE 6或更低版本来做一些事情
<![if gt IE 6]>
Markup used by IE 7, 8 and above, and all other browsers ignoring these proprietary tags...
<![endif]>
这是下层显示的条件评论。安迪·克拉克在他的通用IE6 CSS项目中找到了答案。我推荐他在“为了一个美丽的网站”上写这篇文章,因为他对这个问题有一个具体的解决方法——这可能与你希望执行这个ie6专享的原因相同,也可能不同 根据他的通用IE6 CSS代码: 要隐藏Internet Explorer 6中的所有其他样式表,请将它们包装在此条件注释中
<!--[if ! lte IE 6]><!-->
/* Stylesheets for browsers other than Internet Explorer 6 */
<!--<![endif]-->
<!--[if ! lte IE 6]><!-->
/* Stylesheets for browsers other than Internet Explorer 6 */
<!--<![endif]-->
然后添加UniversalInternetExplorer6样式表
<!--[if lte IE 6]>
<link rel="stylesheet" href="http://universal-ie6-css.googlecode.com/files/ie6.1.1.css" media="screen, projection">
<![endif]-->
<!--[if lte IE 6]>
<link rel="stylesheet" href="http://universal-ie6-css.googlecode.com/files/ie6.1.1.css" media="screen, projection">
<![endif]-->
全文见下文,完整代码见其中的链接:
super从Internet Explorer 6中隐藏所有其他样式表,并将它们包装在此条件注释中
<!--[if ! lte IE 6]><!-->
/* Stylesheets for browsers other than Internet Explorer 6 */
<!--<![endif]-->
<!--[if ! lte IE 6]><!-->
/* Stylesheets for browsers other than Internet Explorer 6 */
<!--<![endif]-->
然后添加UniversalInternetExplorer6样式表
<!--[if lte IE 6]>
<link rel="stylesheet" href="http://universal-ie6-css.googlecode.com/files/ie6.1.1.css" media="screen, projection">
<![endif]-->
<!--[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是的,有些网站仍然需要支持。包括我们现在正在使用的浏览器。@Pekka事实上我们也一样-所以我不知道我在笑什么。这不会被非IE浏览器解析。@Pekka-在Firefox和微软的IE 6中VPC@Pekka-例如,我有一个名为rotate.js的js,我只想在除IE6之外的所有最新浏览器中使用rotate效果。我使用了你的解决方案,但没有渲染js.+1。这比我的更优雅。然而,其他家族的未来浏览器开始支持这些标签的可能性很小,在这种情况下,这将仅限于IE家族。