简体   繁体   English

MS Crm 2011 javascript iframe 函数

[英]MS Crm 2011 javascript Iframe functions

I'm facing a problem with an IFrame on MS CRM 2011. I'm trying to generate HTML code and write it into an IFrame.我在 MS CRM 2011 上遇到 IFrame 问题。我正在尝试生成 HTML 代码并将其写入 IFrame。 I'm quite new to CRM development so I hope you could guide me to a solution.我对 CRM 开发很陌生,所以我希望您能指导我找到解决方案。

After I generate the HTML content (IframeHTML) via JavaScript I try to write that content to an IFrame and then reload the whole Form.通过 JavaScript 生成 HTML 内容 (IframeHTML) 后,我尝试将该内容写入 IFrame,然后重新加载整个表单。 Everything is working fine until I reach my last command一切正常,直到我到达我的最后一个命令

var control = document.getElementById("IFRAME_name");
control.contentWindow.document.open();
control.contentWindow.document.write(IframeHTML);
control.contentWindow.document.close();
control.location.reload(true);

The script is executed on OnLoad of the Form, but it gives me an alert that该脚本在表单的 OnLoad 上执行,但它给了我一个警报

Access is denied访问被拒绝

at the end.在末尾。

If I replace the first line with :如果我用以下内容替换第一行:

var control = Xrm.Page.ui.controls.get("IFRAME_name");

it tells me它告诉我

Document is not supported.不支持文档。

I'm not sure if I recognized what the problem here is so any help would be nice.我不确定我是否意识到这里的问题是什么,所以任何帮助都会很好。

You have to activate Crossframe Scripting in the IFRAME properties.您必须在 IFRAME 属性中激活 Crossframe Scripting。

Have you done that?你这样做了吗?

Regarding the Xrm.Page call, you can get the IFRAME using关于 Xrm.Page 调用,您可以使用 IFRAME

var control = Xrm.Page.ui.controls.get("IFRAME_name").getObject();

This is the supported way to get the IFRAME, so you should use that.这是获取 IFRAME 的受支持方式,因此您应该使用它。

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

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