将光标移到/点击文章中的句子上,可以查看译文。      显示繁体中文内容    显示简体中文内容

How to load the right version of jquery in asp.net/c#?
在 asp.net/c# 中,如何加载正确的jquery版本?

In my asp.net solution, i am loading a jquery library, but i want to use the right version.by this i mean, version 1.10.1 if the browser is IE version 8 or less, and version 2.0.2 if the browser is not IE, or is IE and version 9 or higher.

As well, it needs to take into consideration, which type of doctype and metatag is used.if it ends up doing a IE8 document standards on IE9 or IE10 for example, then it should load the jquery 1.10.1.

This is how i load my jquery library for example in my .ascx file:


<SharePoint:ScriptLink ID="jquery_ui_js" name="/_layouts/jquery-ui-1.10.3.custom.min.js" runat="server" OnDemand="False" Localizable="False"/>

I would prefer to do this check and load the right one in the asp.net code ( .ascx file).

Does anyone know how to do this?

I was thinking about something like this :http://msdn.microsoft.com/en-us/library/ms537512%28v=vs.85%29.aspx

But not sure how to use it here.

时间: 作者:

Conditional comments, like this :


<!--[if lt IE 9]>
 <script src="jquery-1.10.1.js"></script>
<![endif]-->
<!--[if (gte IE 9) | (!IE)]><!-->
 <script src="jquery-2.0.2.js"></script>
<!--<![endif]-->

Obviously, you will need to adjust the paths if necessary, but that is the gist.

原作者:

You can try with migrate plugin also.this will work with latest version of jquery.

for more documentation http://blog.jquery.com/2013/05/01/jquery-migrate-1-2-0-released/

...