For some reason, IE won't execute this script (the 'else' part). I tried almost everything, but I can't manage开发者_运维百科 it working.
$(document).ready(function(){
if (navigator.appName != "Microsoft Internet Explorer") {
$(".f-top").corner("round 10px");
$(".s-top").corner("round 10px");
}
else {
$('.f-top').css('background-image', 'url(../images/block-bg.png)');
}
});
I am assuming you are using jQuery - if so...
Use:
!$.browser.msie
Instead of:
navigator.appName != "Microsoft Internet Explorer"
If you are using jQuery, why don't you use the following?
if ($.browser.msie) {
// do your thing if browser is Internet Explorer
}
else {
// do your thing if browser is not Internet Explorer
}
Not directly answering your question, but it looks like you're trying to use JQuery to hack in rounded corners into your elements.
If you must use JQuery for this, there are plenty of good plugins already available which are better than your solution. Here's one: http://www.jqueryplugins.com/plugin/61/
But frankly, the best way to do rounded corners in IE (all versions) is to forget about using JQuery, and use CSS3Pie instead.
CSS3Pie is a small IE-specific hack which goes in your stylesheet, and makes IE work with the standard border-radius
CSS property (which already works in all other browsers).
So all you need to have rounded corners is the following CSS:
#myElement {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
behavior: url(PIE.htc);
}
Very easy, works well, and allows you to use standard CSS for all browsers.
See the examples and documentation on the CSS3Pie website for more details.
精彩评论