什么是jQuery的包括在DotNetNuke的4.8.x的最佳方式? [英] What is the best way to include jQuery in DotNetNuke 4.8.x?

查看:131
本文介绍了什么是jQuery的包括在DotNetNuke的4.8.x的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的DotNetNuke 4.8.x,想利用jQuery的。任何人都可以提出可能我对什么是jQuery的融入DNN的最佳方式?我将不能够DNN版本升级到5已内置支持jQuery的。

您的建议是多AP preciated。


解决方案

要避免负载的jQuery多次,它可能是最好使用客户端脚本,如给予的这里

在服务器端,您可以在页眉的Page.Init或Page.Load事件过程中加载jQuery库:

 保护小组Page_Init(BYVAL发件人为对象,BYVAL E上EventArgs的)把手MyBase.Init
   Page.Header.Controls.Add(...)
结束小组

您可能需要使用一个辅助方法来创建HtmlGenericControl,像

 公共功能HeadScriptResource(SRC BYVAL作为字符串)作为HtmlGenericControl    DIM包括作为新HtmlGenericControl(剧本)
    Include.Attributes.Add(型,文/ JavaScript的)
    Include.Attributes.Add(src用户,SRC)
    返回包含结束功能

这样,您就可以添加任何脚本中使用的源路径作为参数传递给头:

<$p$p><$c$c>Page.Header.Controls.Add(HeadScriptResource(\"/resources/shared/scripts/jquery/jquery.min.js\"))

DNN 4.9.1及以上附带位于jQuery的


  

/resources/shared/scripts/jquery/jquery.min.js


如果每次你需要服务器具有网络访问,这是不是在企业环境中显而易见的,可以使用托管的jQuery,例如:
http://ajax.googleapis.com/ajax/libs /jquery/1.4.2/jquery.min.js

通过托管的jQuery,你如果网站使用HTTPS使用HTTPS URL。否则,你会得到浏览器的警告。这可能是更容易为始终使用https。

如果您需要添加的jQuery页逐页的基础上,还可以使用页眉标签页中设置的建议<一href=\"http://blog.theaccidentalgeek.com/post/2009/05/26/DotNetNuke-Tips-and-Tricks-11-Using-jQuery-in-DotNetNuke.aspx\"相对=nofollow>这里。

另请参阅:

I'm using DotNetNuke 4.8.x and want to utilize jQuery. Could anyone possibly suggest me on what is the best way to integrate jQuery into DNN? I won't be able to upgrade DNN version to 5 which has built-in support for jQuery.

Your advice would be much appreciated.

解决方案

To avoid loading jQuery multiple times, it might be best to use a client-side script, like the one given here.

In the server-side, you can load jQuery library in the page header during the Page.Init or Page.Load event:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Init
   Page.Header.Controls.Add(...)
End Sub

You may want to use a helper method to create the HtmlGenericControl, like

Public Function HeadScriptResource(ByVal src As String) As HtmlGenericControl

    Dim Include As New HtmlGenericControl("script")
    Include.Attributes.Add("type", "text/javascript")
    Include.Attributes.Add("src", src)
    Return Include

End Function

This way, you can add any script to header using the source path as parameter:

Page.Header.Controls.Add(HeadScriptResource("/resources/shared/scripts/jquery/jquery.min.js"))

DNN 4.9.1 and above are shipped with jQuery located in

/resources/shared/scripts/jquery/jquery.min.js

If every server you need has web access, which is not evident in corporate environments, you can use hosted jQuery, for example: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

With hosted jQuery, you have to use the https url if the site uses https. Otherwise, you'll get browser warnings. It may be easier to always use https.

If you need to add jQuery on page-by-page basis, you can also use Page Header Tag in Page Settings as suggested here.

See also:

这篇关于什么是jQuery的包括在DotNetNuke的4.8.x的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆