Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

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. I'm quite new to CRM development so I hope you could guide me to a solution.

After I generate the HTML content (IframeHTML) via JavaScript I try to write that content to an IFrame and then reload the whole Form. 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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have to activate Crossframe Scripting in the IFRAME properties.

Have you done that?

Regarding the Xrm.Page call, you can get the IFRAME using

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

This is the supported way to get the IFRAME, so you should use that.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...