本文介绍了使用Js按名称隐藏sharePoint子网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是获取我并显示我所有子站点的代码.问题是我需要显示所有子站点,而不是需要隐藏"Test3"的子站点.使用javascript.
This is the code that get me and display all my subsite. The problem is I need Display all subsites instead of one that I need to hide "Test3" using javascript.
<html>
<script>
ExecuteOrDelayUntilScriptLoaded(RetriveSites,"sp.js");
function RetriveSites()
{
currentcontext = new SP.ClientContext.get_current();
currentweb = currentcontext.get_web();
//this.subsites = currentweb.get_webs();
this.subsites = currentweb.getSubwebsForCurrentUser(null);
currentcontext.load(this.subsites);
currentcontext.executeQueryAsync(Function.createDelegate(this, this.ExecuteOnSuccess),
Function.createDelegate(this, this.ExecuteOnFailure));
}
function ExecuteOnSuccess(sender, args) {
var subsites = '';
var enum1 = this.subsites.getEnumerator();
var el = document.getElementById('LKMSubWebs');
while (enum1.moveNext())
{
var Site = enum1.get_current();
//alert('hi123');
subsites += '\n' + '<a class=subsitecls href='+ Site.get_serverRelativeUrl()+'>'+Site.get_title()+'</a> </br>'
//RootElement.append('<a class=subsitecls href='+ siteTitle+'>'+siteTitle+'</a> </br>');
//alert(subsites);
}
el.innerHTML = subsites;
}
function ExecuteOnFailure(sender, args) {
alert("error");
//alert(args.get_message());
}
</script>
<div id="LKMSubWebs"></div>
</html>
谢谢
thank you
推荐答案
function ExecuteOnSuccess(sender, args) {
var subsites = '';
var enum1 = this.subsites.getEnumerator();
var el = document.getElementById('LKMSubWebs');
while (enum1.moveNext())
{
var Site = enum1.get_current();
if (Site.get_title() == "Test3") {
continue;
}
//alert('hi123');
subsites += '\n' + '<a class=subsitecls href='+ Site.get_serverRelativeUrl()+'>'+Site.get_title()+'</a> </br>'
//RootElement.append('<a class=subsitecls href='+ siteTitle+'>'+siteTitle+'</a> </br>');
//alert(subsites);
}
el.innerHTML = subsites;
}
这篇关于使用Js按名称隐藏sharePoint子网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!