在office 365(sharepoint online)上使用javascript创建网站集

在office 365(sharepoint online)上使用javascript创建网站集,javascript,sharepoint,sharepoint-2013,office365,Javascript,Sharepoint,Sharepoint 2013,Office365,我想用javascript创建一个网站集,但我在网上找不到任何东西 谢谢。假设您使用的是sharepoint托管的应用程序 //create sp context and get root var clientContext = new SP.ClientContext.get_current(); var rootWeb = clientContext.site.rootWeb(); this.clientContext.load(rootWeb); this.clientContext.ex

我想用javascript创建一个网站集,但我在网上找不到任何东西


谢谢。

假设您使用的是sharepoint托管的应用程序

//create sp context and get root
var clientContext = new SP.ClientContext.get_current();
var rootWeb = clientContext.site.rootWeb();
this.clientContext.load(rootWeb);
this.clientContext.executeQUery();

//set web info
var webInfo = new SP.WebCreationInformation();
webInfo.set_webTemplate('YourTemplateName');
webInfo.set_description('Your site description');
webInfo.set_title('Your site tittle');
webInfo.set_url(siteUrl);
webInfo.set_language(yourLangCode);
this.rootWeb.get_webs().add(webInfo);
this.rootWeb.update();

// save site and set callbacks
this.clientContext.load(this.rootWeb);
this.clientContext.executeQueryAsync(
    Function.createDelegate(this, this.OnSiteCreationSuccess),
    Function.createDelegate(this, this.Error));

请记住,您的模板必须使用您使用的语言代码保存,否则将引发未找到的异常。

Javascript是客户端语言-您将很难使用Javascript创建网站集。。