Sharepoint 用于在快速启动中填充页面的Java脚本
我正在使用一个维基网站。我想知道是否有办法填充从页面库创建的页面,以便自动添加到quick launch?中?。否则每次我都会从导航中手动添加它们Sharepoint 用于在快速启动中填充页面的Java脚本,sharepoint,sharepoint-online,Sharepoint,Sharepoint Online,我正在使用一个维基网站。我想知道是否有办法填充从页面库创建的页面,以便自动添加到quick launch?中?。否则每次我都会从导航中手动添加它们 如果是这样的话,是否有我可以使用的示例代码?请参考下面的代码示例,了解如何使用javascript向quick launch添加链接 这是工作代码。您可以根据需要修改此代码并直接使用 var quickLaunchNodeCollection = null; var oNewNaviNode = null; function addNavigati
如果是这样的话,是否有我可以使用的示例代码?请参考下面的代码示例,了解如何使用javascript向quick launch添加链接 这是工作代码。您可以根据需要修改此代码并直接使用
var quickLaunchNodeCollection = null;
var oNewNaviNode = null;
function addNavigationNodes() {
var context = new SP.ClientContext.get_current();
if (context != undefined && context != null) {
var web = context.get_web();
//this.navigationNodeCollection = web.get_navigation().get_topNavigationBar();
this.quickLaunchNodeCollection = web.get_navigation().get_quickLaunch();
// Set properties for a new navigation node.
this.oNewNaviNode = new SP.NavigationNodeCreationInformation();
oNewNaviNode.set_title("NewNavigationNode");
oNewNaviNode.set_url("http://www.google.com");
oNewNaviNode.set_asLastNode(true);
this.quickLaunchNodeCollection.add(oNewNaviNode);
context.load(this.quickLaunchNodeCollection);
context.executeQueryAsync(addNavigationNodesSuccess, addNavigationNodesFailed);
}
}
function addNavigationNodesSuccess() {
alert("New node added...");
}
function addNavigationNodesFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
下面是如何使用javascript向quick launch添加链接的代码示例 这是工作代码。您可以根据需要修改此代码并直接使用
var quickLaunchNodeCollection = null;
var oNewNaviNode = null;
function addNavigationNodes() {
var context = new SP.ClientContext.get_current();
if (context != undefined && context != null) {
var web = context.get_web();
//this.navigationNodeCollection = web.get_navigation().get_topNavigationBar();
this.quickLaunchNodeCollection = web.get_navigation().get_quickLaunch();
// Set properties for a new navigation node.
this.oNewNaviNode = new SP.NavigationNodeCreationInformation();
oNewNaviNode.set_title("NewNavigationNode");
oNewNaviNode.set_url("http://www.google.com");
oNewNaviNode.set_asLastNode(true);
this.quickLaunchNodeCollection.add(oNewNaviNode);
context.load(this.quickLaunchNodeCollection);
context.executeQueryAsync(addNavigationNodesSuccess, addNavigationNodesFailed);
}
}
function addNavigationNodesSuccess() {
alert("New node added...");
}
function addNavigationNodesFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
这是我最初发布这个答案的链接——谢谢rohith。如何将页面库中的页面引用到此。我看到它将google.com添加到快速启动中。我可以使用内容编辑器或脚本编辑器直接使用此代码吗?@Rinu您可以在内容编辑器中直接使用此代码。但是您必须手动将页面标题和Url传递到此代码。是否有某种方法可以自动添加标题和Url。web变量是否能够从pages库中获取内容,并使用for循环或其他方法填充?这是我最初发布此答案的链接,谢谢rohith。如何将页面库中的页面引用到此。我看到它将google.com添加到快速启动中。我可以使用内容编辑器或脚本编辑器直接使用此代码吗?@Rinu您可以在内容编辑器中直接使用此代码。但是您必须手动将页面标题和Url传递到此代码。是否有某种方法可以自动添加标题和Url。web变量是否能够从pages库中获取内容,并使用for循环或其他方法进行填充