When I click on an item in a list I get to the detailed view. There I need the title of this item. I could find it in the title of the page (when you look on the tab of your browser) but I think it's not cool.

Is there an object with a method or attribute?

I have tried _spPageContextInfo. but it does not have the information I need. Also I found no way to use SP.ClientContext.

I have to use JavaScript because its part of a JSLink-Project. So I cannot use SharePoint designer either.

  • Is the title of the list item displayed in the form? And you just want to be able to get that title into a JavaScript variable or something? – Submits Mar 2 '15 at 15:53
  • yes! its also listed on the page (so i could search the div ... and then get the innerHTML ... but yes i think there is a smarter solution). and yes, i just need it in a variable. – user39753 Mar 2 '15 at 15:57
  • There really is no need for a smarter solution. Interrogating the DOM to get the Title is a sufficient solution. – Submits Mar 2 '15 at 15:59
  • But when i search for the div-id and in the future the the id changes? I'm able to search for so many informations over the SP-Objects so i thought this is not a big thing – user39753 Mar 2 '15 at 16:07

A method that does not include the DOM:

var getTitle = function() {
    var id = getUrlVar('ID'),
        listId = _spPageContextInfo.pageListId.removeBraces(),
        ctx = SP.ClientContext.get_current(),
        list = ctx.get_web().get_lists().getById(listId),
        item = list.getItemById(id);

    ctx.load(item, 'Include(Title)');
    ctx.executeQueryAsync(success, failure);
getUrlVar = function(param) {
    var query = window.location.search.substr(1),
        params = query.split('&');
    for(var i = 0, kvPair; kvPair = params[i]; i++){
        var key = kvPair.split('=')[0];
        if(key = param) return kvPair.split('=')[1];
String.prototype.removeBraces = function() {
    return this.substr(0, this.length - 1).substr(1);

Do what you need to do with the title in the success callback

| improve this answer | |

If you don't want to interrogate the DOM to get the item's Title value then you can use the Client Object Model implemented with JavaScript (aka JavaScript Object Model).

See below for an example:


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.