I have a custom aspx page loaded in a IFrame in one of the modules in MS CRM 4.0. This page basically has 6 textboxes (txtValue1, txtValue2 and so on..) with values in it. I want to access these values through javascript code either on the load event or save event. Does anybody know how to do it ? I tried couple of codes that i got from net but nothing seems to work. Any help on this would appreciated.
我在MS CRM 4.0的一个模块中的IFrame中加载了一个自定义的aspx页面。这个页面基本上有6个文本框(txtValue1,txtValue2等等......),其中包含值。我想通过加载事件或保存事件的javascript代码访问这些值。有谁知道怎么做?我尝试了几个从网上获得的代码,但似乎没有任何效果。对此有任何帮助表示赞赏。
2 个解决方案
#1
1
Try the following snippet...
请尝试以下代码段...
var textBox1Value = document.frames.IFRAME_NAME.document.all.txtValue1.value;
where IFRAME_NAME is the name of the IFRAME you define in the form customizations and txtValue1 is the id of the textbox on the IFRAME.
其中IFRAME_NAME是您在自定义表单中定义的IFRAME的名称,而txtValue1是IFRAME上文本框的ID。
#2
1
One little gotcha that's worth noting is that accessing the iframe via the document's frames collection won't let you read or write the src or url properties that I find myself dynamically changing every now and again. To access and change the properties, you'll need to access the iframe via getElementById
.
值得注意的一点是,通过文档的框架集合访问iframe将不会让您读取或写入我发现自己动态地改变的src或url属性。要访问和更改属性,您需要通过getElementById访问iframe。
var yourIframe = document.getElementById('IFRAME_NAME');
Note that if you access the iframe as above and you want to call a function that is available to the iframe's scripts, you have to call it via the contentWindow property:
请注意,如果您按上述方式访问iframe并且想要调用iframe脚本可用的函数,则必须通过contentWindow属性调用它:
yourIframe.contentWindow.someFuncOnIframePage();
#1
1
Try the following snippet...
请尝试以下代码段...
var textBox1Value = document.frames.IFRAME_NAME.document.all.txtValue1.value;
where IFRAME_NAME is the name of the IFRAME you define in the form customizations and txtValue1 is the id of the textbox on the IFRAME.
其中IFRAME_NAME是您在自定义表单中定义的IFRAME的名称,而txtValue1是IFRAME上文本框的ID。
#2
1
One little gotcha that's worth noting is that accessing the iframe via the document's frames collection won't let you read or write the src or url properties that I find myself dynamically changing every now and again. To access and change the properties, you'll need to access the iframe via getElementById
.
值得注意的一点是,通过文档的框架集合访问iframe将不会让您读取或写入我发现自己动态地改变的src或url属性。要访问和更改属性,您需要通过getElementById访问iframe。
var yourIframe = document.getElementById('IFRAME_NAME');
Note that if you access the iframe as above and you want to call a function that is available to the iframe's scripts, you have to call it via the contentWindow property:
请注意,如果您按上述方式访问iframe并且想要调用iframe脚本可用的函数,则必须通过contentWindow属性调用它:
yourIframe.contentWindow.someFuncOnIframePage();