Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

CEWP Question

  Asked By: Michael    Date: Sep 16    Category: Sharepoint    Views: 859

I want to create a CEWP that references jQuery stored in a document library on
the root-level site of a site collection. I can easily code the following:

<script type="text/javascript"

However, I don't want to hard-code the url in the 'src' section.

Can someone provide an example on how to use something like "~sitecollection"?



4 Answers Found

Answer #1    Answered By: Delilah Mcpherson     Answered On: Sep 16

If you don't have any site  collections in managed paths, you can just use a
leading slash on your relative path, e.g.


Answer #2    Answered By: Gobinda Navalagi     Answered On: Sep 16

Something like this?


Answer #3    Answered By: Rose Silva     Answered On: Sep 16

I did a search on MSDN and it appears that the following example  will work:

<script type="text/javascript"

It looks like you can also use a site  relative url. Example:
<script type="text/javascript" src="~site/jQueryLibrary/jquery.min.js"></script>

Answer #4    Answered By: Maegan Ellison     Answered On: Sep 16

If you're going to do that, why not just use the leading slash, which means
the same thing as "http://hostname/" ?

Didn't find what you were looking for? Find more on CEWP Question Or get search suggestion and latest updates.