简体   繁体   中英

Setting document.title not working in Dynamics CRM 2011 JScript

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 (ie 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?

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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