IE-only JavaScript not working?
IE-only JavaScript not working?
我遇到了麻烦,让我的IE只加载样式表,所以我解决了一些IE只内联javascript。
但这也不起作用。有人可以看看我的代码,告诉我我做错了什么?我目前把它放在一个script标签在我的html文档的末尾,就在我的html结束标签的上方。
下面是我的代码:<script>
if ($.browser.msie && $.browser.version < 8) {
// IE 7 or older
$('.sidecolor, .EDGE-15678806, .edge-wrapper').css("display", "none");
$('.MobileBanner').css("display", "block");
} else {
// all other browsers
$('.sidecolor, .EDGE-15678806, .edge-wrapper').css("display", "block");
$('.MobileBanner').css("display", "none");
}
</script>
首先,我建议您使用这个作为一个简单的测试,您可以在script
标记之间插入您的代码,一旦您看到它为您工作:
<!--[if lt IE 8]>
<script>
alert("This is some version of IE, either 7 or below, so very not awesome!);
/*Your code here*/
</script>
<!--[if (gte IE 8) | (!IE)]><!-->
<script>
alert("This is some version of IE, either 8 or above, much better!);
/*Your code here*/
</script>
<!--<![endif]-->
让我知道这是否有帮助。如果它没有,那么它可能与你的元素或你的CSS样式有关,这完全是另一个问题。
对进一步测试的参考:MSDN '关于条件注释'
相关文章:
- $rootScope not working
- jQuery document.ready not working
- Javascript getElementsByTagName not working?
- JQuery.val( ) not working
- Tomcat websocket is not working
- Javascript JSON.parse not working
- NodeJS Multer is not working
- Regex not working
- Ember run.debounce not working
- AngularJs 1 not working
- document.getElementById.style.backgroundImage not working
- Rxjs5, distinct() is not working
- createOscillator noteOn not working
- Javascript - .getHours() not working
- Javascript setTimeout not working | onkeydown
- MongoDB $pull not working
- Express router.use not working
- JSONP not working
- window.opener not working in chrome & IE
- Backbone + RequireJS: Collection.each() is not working