SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A common web development trick is to use protocol-relative URL's, i.e. we drop the scheme part of the URL, e.g. http, and based on the scheme of the page the URL's take will use that scheme.

However it seems that SharePoint doesn't like these - as it add's back the scheme in the CEWP or drops the URL completely if you are using the web services.

I suspect you could do the embedding code trick for these too but that is tough to get users to understand and won't work with lists.

So what, if any, solutions are there to this that would allow me to use protocol relative URLs?

share|improve this question

Yes I believe SharePoint does the same thing even if you don't include type="text/javascript" in your script tags in a CEWP.

You could try using something like something like:

<script type="text/javascript">

document.write("<script type='text/javascript' src='"+ window.location.protocol +"//path/to/your/file.js'></script>");


window.location.protocol will always contain http: or https: depending upon your environment.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.