繁体   English   中英

在Office 365上使用JavaScript创建网站集(在线共享点)

[英]Creating site collection with javascript on office 365 (sharepoint online)

我想使用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));

请记住,您的模板必须与您使用的langCode保存在一起,否则它将引发未找到的异常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM