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?

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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