2012-11-19 35 views
2

我在MS Dynamics CRM 2011表单上的OnLoad事件中运行了一段JScript代码,并且希望设置文档标题(即,在IE窗口/通过该脚本。设置document.title在Dynamics CRM 2011中不起作用JScript

我已经做了以下调用:

document.title = newtext; 

,但是这是行不通的。当我检查使用F12发生的事情时,我发现预先存在的document.title值是“Holding:”。但是,我的浏览器中实际选项卡的document.title是“Holding: - Microsoft Dynamics CRM”

我认为问题可能是我在一个子表单(或者可能是一个iFrame?)而不是在用户导航到的实际文档。有什么方法可以设置父文档的标题吗?

回答

2

不知道这是否会为你工作,但是这是我们的setDisplayName功能会同时更新标题和CRM事业部显示名称:

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

这是完美的,谢谢。 parent.document.title取得了诀窍。我真的应该为自己想出来:) –