简体   繁体   English

从IFRAME分配主窗口中的字段值

[英]Assigning a value of a field in the main window from IFRAME

In an IFRAME there's a value declared by var blipp = 7; IFRAME中,有一个由var blipp = 7;声明的值var blipp = 7; . In the main window, I there's a field called new_blopp . 在主窗口中,我有一个名为new_blopp的字段。 I'd be delighted to get blipp into blopp . 我很高兴能把blipp变成blopp According to this MSDN discussion , it can be done by one of the following methods. 根据此MSDN讨论 ,可以通过以下方法之一完成此操作。

  1. parent.window.Xrm.Page.data.entity.attributes.get("new_blopp").setValue(blipp)
  2. _mainWindow.parent.parent.document.all["new_blopp"].innerText = blipp

I'm not entirely sure why he's also suggesting to type in the following. 我不确定他为什么还建议输入以下内容。

_mainWindow.parent.parent.document.all["new_blopp"].value = ""

In any case, neither of them seem to be working. 无论如何,它们似乎都不起作用。 The first gives me permission denied and the second '_mainWindow' is not defined . 第一个给我权限被拒绝 ,第二个'_mainWindow'未定义 Of course, I have unchecked the cross frame scripting. 当然,我没有检查跨框架脚本。 According to F12, there's a field called data in parent.window.Xrm.Page but it's null . 根据F12, parent.window.Xrm.Page中存在一个名为data的字段,但该字段为null When I hit debugger, I can see that parent is accessible but not parent.window - permission denied is what I get there. 当我点击调试器时,我可以看到parent是可访问的,但parent.window无法访问 - 拒绝权限是我到达那里的目的。

How can I convey the wisdom of blipp to blopp ? 我如何将blipp的智慧传达给blopp

It's even more frustrating because this post and this one suggest my code should work. 更加令人沮丧的是,因为这篇文章这篇 文章表明我的代码应该可以工作。 does it have to do with the fact that I'm running on-line version? 我运行的是在线版本吗?

If both iframe and parent are in the same domain. 如果iframeparent都在同一个域中。 (pure javascript ) (纯javascript

To get blipp (in iframe) into blopp (in parent) blipp (in iframe)转换为blopp (in parent)

var blopp = document.getElementById("ifameId").contentWindow.blipp;

To get blopp (in parent) into blipp (in iframe) 要将blopp (in parent)放入blipp (in iframe)

var blipp = self.parent.window.blopp;

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

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