您如何在 html 页面中添加 jquery 作为动态 crm 2011 中的网络资源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5232968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how do you add jquery in a html page as a web resource in dynamics crm 2011
提问by Calibre2010
having a lot of trouble with this one. I am trying to run a simple jquery script inside of an html page to just pop up an alert box.
这个有很多麻烦。我正在尝试在 html 页面内运行一个简单的 jquery 脚本来弹出一个警告框。
I have uploaded the jquery library and the json library
我已经上传了 jquery 库和 json 库
I have an html page with the following references and the reference to my jquery script. It is not coming up with the alert however when I embed this html as an iframe.
我有一个 html 页面,其中包含以下引用和对我的 jquery 脚本的引用。然而,当我将此 html 嵌入为 iframe 时,它并没有出现警报。
<SCRIPT src="../ClientGlobalContext.js.aspx"></SCRIPT>
<SCRIPT type=text/javascript src="../jquery1.4.1.min.js"></SCRIPT>
I was reading something about relative paths and what have you I have tried
我正在阅读有关相对路径的内容以及我尝试过的内容
<SCRIPT type=text/javascript src="../Script/jquery1.4.1.min.js"></SCRIPT>
<SCRIPT type=text/javascript src="../Scripts/jquery1.4.1.min.js"></SCRIPT>
both.
两个都。
But its not working.
但它不起作用。
回答by EndangeredMassa
I see two options available to you.
我看到两个选项可供您使用。
Option 1: Relative PathsWeb Resources can point to each other via relative paths. So, it really depends on the "Name" of your html web resource and your jquery web resources.
选项 1:相对路径Web 资源可以通过相对路径相互指向。因此,这实际上取决于您的 html 网络资源和 jquery 网络资源的“名称”。
The "Name" of a web resource cannot be changed after it has been created. So, you want to pay close attention to this. (You can always delete it and create it again with a new name, though.) This Name value can have a path in it.
网络资源的“名称”一经创建便无法更改。所以,你要密切注意这一点。(不过,您始终可以删除它并使用新名称重新创建它。)此 Name 值中可以包含路径。
For example, your jQuery library web resource might have a Name of "/Scripts/jquery.js". If you html page (that your iframe points to) has a name of "/Pages/mypage.html", then that html page must reference the jQuery library like so:
例如,您的 jQuery 库 Web 资源的名称可能为“/Scripts/jquery.js”。如果您的 html 页面(您的 iframe 指向)的名称为“/Pages/mypage.html”,则该 html 页面必须像这样引用 jQuery 库:
<script src="../Scripts/jquery.js"></script>
It has to go up a level to get out of the Pages folder, then down into the Scripts folder, and hits the jquery.js file. You can think of this as a real file system, as if you were working with a regular ASP.NET site.
它必须上升一个级别才能离开 Pages 文件夹,然后进入 Scripts 文件夹,然后点击 jquery.js 文件。您可以将其视为真正的文件系统,就好像您正在使用常规 ASP.NET 站点一样。
Option 2: CDNGoogle (and other networks) host libraries like jQuery on their Content Delivery Networks (CDN). They designed these to be extremely fast and reliable. If you don't mind requiring a connection to the internet for your functionality to work, you can link directly to jquery on Google's CDN.
选项 2:CDNGoogle(和其他网络)在其内容交付网络 (CDN) 上托管 jQuery 等库。他们将这些设计为非常快速和可靠。如果您不介意需要连接到 Internet 才能使您的功能正常工作,您可以直接链接到 Google CDN 上的 jquery。
To do this, change your script tag for jQuery to this:
为此,请将 jQuery 的脚本标记更改为:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>