簡體   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