简体   繁体   English

设置 document.title 在 Dynamics CRM 2011 JScript 中不起作用

[英]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.我正在 MS Dynamics CRM 2011 表单上的 OnLoad 事件中运行一段 JScript 代码,并希望通过脚本设置文档标题(即该页面的 IE 窗口/选项卡中显示的内容)。

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: ".当我使用 F12 检查正在发生的事情时,我看到预先存在的 document.title 值是“Holding:”。 However, the document.title of the actual tab in my browser is "Holding: - Microsoft Dynamics CRM"但是,浏览器中实际选项卡的 document.title 是“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.我认为问题可能在于我在子表单(或者可能是 iFrame?)中工作,而不是在用户导航到的实际文档中工作。 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:不确定这是否适合您,但这是我们的 setDisplayName 函数,它更新标题和 CRM Div 显示名称:

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

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

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