2
votes

I am running a piece of JScript code in the OnLoad event on an MS Dynamics CRM 2011 form, and wish to set the document title (i.e what's displayed in the IE window/tab for this page) through the script.

I have made the following call:

document.title = newtext;

but this is not working. When I inspect what is happening using F12, I see that the pre-existing document.title value is "Holding: ". However, the document.title of the actual tab in my browser is "Holding: - Microsoft Dynamics CRM"

I think the problem may be that I am working in a subform (or maybe an iFrame?) rather than in the actual document that the user is navigated to. Is there any way I can set the parent document's title?

1

1 Answers

2
votes

Not sure if this will work for you, but this is our setDisplayName function that updates both the title, and the CRM Div display name:

/*
Updates the display name of the entity, both in the name div, and the Page Title
*/
setDisplayName: function (name) {        
    // Updates the Document Title
    var title = parent.document.title;
    var start = title.indexOf(':') + 2;
    var end = title.lastIndexOf('-') - 1;    
    parent.document.title = title.substring(0, start) + name + title.substring(end);

    // Sets the div Name
    document.getElementById("form_title_div").childNodes[2].childNodes[0].innerText = name;
}