0

I've followed one of the tutorials to use CSOM (JavaScript) to work on a list. I need to template the site and create new sites from it.

But in my code (CEWP and txt file) I have a hard coded link. Is it somehow possible to change to grab site collection (itdevSC) ?

var siteUrl = '/sites/itdevSC/mysubsite';     
var clientContext = new SP.ClientContext(siteUrl);
0

You can get the URL using

var siteUrl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;
  • 1
    Or directly use _spPageContextInfo.siteAbsoluteUrl instead of concatenating protocol and host info from window.location – Nadeem Yousuf Nov 18 '14 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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