Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

how do you add jquery in a html page as a web resource in dynamics crm 2011

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.

I have uploaded the jquery library and the json library

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.

 <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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I see two options available to you.

Option 1: Relative Paths Web 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.

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.

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:

<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.

Option 2: CDN Google (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.

To do this, change your script tag for jQuery to this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...