Take the 2-minute tour ×

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
add comment

1 Answer

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
add comment

Your Answer


