繁体   English   中英

如何更改当前页面标题?

[英]How to change current page title?

这是我的简单代码。 currentItem.update(); 不起作用,我也不知道为什么。 你能帮我吗?

$(document).ready(function () {

    context = new SP.ClientContext.get_current();
    web = context.get_web();
    list = web.get_lists().getById(_spPageContextInfo.pageListId);
    currentItem = list.getItemById(_spPageContextInfo.pageItemId)
    context.load(currentItem);
    context.executeQueryAsync(onQuerySucceeded, onQueryFailed);

    function onQuerySucceeded() {
        currentItem.set_item('Title', 'Test');
        currentItem.update();
    }

    function onQueryFailed(sender, args) {
        alert("Error");
    }

})

没有简单的答案,这取决于母版页...如果母版页设置为显示页面的属性作为标题,则该解决方案应该起作用。 例如,如果它具有以下内容:

<title><SharePoint:ListItemProperty runat="server" Property="Title"/></title>

否则,它可能具有静态定义的标题,在这种情况下,它将不使用该属性。

暂无
暂无

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

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