Jquery 基于浏览器版本的不同内容?

Jquery 基于浏览器版本的不同内容?,jquery,internet-explorer,content-management-system,browser,dotnetnuke,Jquery,Internet Explorer,Content Management System,Browser,Dotnetnuke,是否可以根据用户使用的浏览器在CMS DNN中显示不同的内容?例如,如果IE 7显示内容1 IE7不太喜欢图像映射,我只是向用户展示我制作的流程图的静态图像 <!--[if IE 7]> Special instructions for IE 7 here <![endif]--> 我想编写一些jquery代码来删除该页面内容窗格中div类的内容,因此检查文件扩展名process.aspx,然后在隐藏的div中启用图像。您可以使用jquery.browser方法: 这里

是否可以根据用户使用的浏览器在CMS DNN中显示不同的内容?例如,如果IE 7显示内容1

IE7不太喜欢图像映射,我只是向用户展示我制作的流程图的静态图像

<!--[if IE 7]>
Special instructions for IE 7 here
<![endif]-->
我想编写一些jquery代码来删除该页面内容窗格中div类的内容,因此检查文件扩展名process.aspx,然后在隐藏的div中启用图像。您可以使用jquery.browser方法:


这里,获取IE版本的JS方法返回-1(如果不是IE):

function isUndefined(e) {
    return typeof e === "undefined";
}

function getIEVersion() {
    var style = document.body.style;
    var version = -1;
    if(!isUndefined(style.scrollbar3dLightColor)) {
        if (!isUndefined(style.opacity)) version = 9;
        else if (!isUndefined(style.msBlockProgression)) version = 8;
        else if (!isUndefined(style.msInterpolationMode)) version = 7;
        else if (!isUndefined(style.textOverflow)) version = 6;
        else version = 5;
    }
    return version;
}
然后,使用jQuery:

$(function() {
    if(getIEVersion() == 7) {
        $('#content-pane').hide();
        $('#hidden-div').show();
    }
});

老实说,你可以用CSS来做这件事

你有两份内容吗

<div class="ForEveryone">
<!-- Your stuff here -->
</div>

<div class="ForIE7">
<!-- Code for less helpful browser here -->
</div>
然后使用IE7特定的样式表将其更改为

.ForEveryone { display: none; }
.ForIE7 { display: block; }

无需使用javascript进行此操作。

那么,您想使用JS检测用户使用的浏览器,就这样吗?在编辑中添加了更多信息。我在jQuery.browser方法中遇到了一些问题。最后,我更喜欢使用基于CSS的浏览器检测。
.ForIE7 { display: none; }
.ForEveryone { display: none; }
.ForIE7 { display: block; }