【发布时间】:2013-03-29 17:19:15
【问题描述】:
我需要自动化一个使用 iframe 嵌入子“表单”的 Web 表单,这些子“表单”可以被视为单独的 html 页面。
因此,您会得到一个父文档,其中包含他们称为 iframe 的视图字段。 iframe 内是“子”嵌入网页。
一个简单的例子:
我已经从 html 中删减了很多以将其缩小到合理的大小
<html>
<body>
<div id="123" arid=123 artype="View" ardbn="vfMyChild"
class="arfid123 ardbnvfMyChild"
STYLE="top:49 left:75 width:1038 height:322" arvfframe="<iframe style="top:0 left:0 width:1038; height:322" name="VF123" title="View Field" src="javascript:&quot;&lt;HTML&gt;&lt;/HTML&gt;&quot;" >
</iframe>">
</div>
</body>
</html>
那么嵌入的子html可以像这样简单:
<html>
<body>
<div id="321" arid=321 artype="Char" ardbn="txtRegister">
<label id="label321" class="label f6">Register:</label>
<textarea id="arid_321" cols="20" maxlen=255 rows=1></textarea>
</div>
</body>
</html>
STYLE= 中包含的 html 看起来有点奇怪 - 不知道为什么会这样。但我可以看到它有点像 iframe。
我有一个顶级文档对象的实例,我有一个 id=123 的 div 实例。我需要自动化孩子中的 textarea 对象。我尝试了以下方法,但没有成功。
var viewfields; //is a ref to the div with id=123
if(viewfields) {
window.alert("viewfields.length=" + viewfields.length); //prints len=1 as expected
// line below get Caught exception: Unable to get value of the
// property 'document': object is null or undefined
var innerDoc = viewfields[0].contentDocument || viewfields[0].contentWindow.document;
if(innerDoc) {
window.alert("Wohoo we have an innerDoc");
}
} else
window.alert("no view fields found");
我正在使用 IE9 进行测试。
我能否使用此 html 获取内部网页的实例?如果有,怎么做?
编辑
如果有帮助,这里是相关 div 的实际未经编辑的 html。
<div id="WIN_0_536870915" arid=536870915 artype="View" ardbn="vfCubaChildren" class="arfid536870915 ardbnvfCubaChildren" STYLE="top:49; left:75; width:1038; height:322;z-index:1001;background-color:transparent;" arvfframe="<iframe style="top:0&#59; left:0&#59; width:1038&#59; height:322&#59;background-color: transparent&#59;" name="VF536870915" frameborder=1 scrolling="auto" allowtransparency="true" title="View Field" src="javascript:&quot;&lt;HTML&gt;&lt;/HTML&gt; ;&quot;" onload="DVFol&#40;&#41;">
</iframe>">
</div>
该 div 包含子窗体。子窗体就像另一个 html 网页。它具有标准的 html 输入字段和 textarea。我需要将文本发布到孩子(来自父母)的文本区域。但问题是我还不能从父级访问子 html 对象。
【问题讨论】:
-
我可能不知道您在使用什么,但指定的
arid、artype、ardbn和arvfframe元素属性是什么? -
我以为你说 viewfields 是
iframe中的div,但你把它当作数组对待?此外,它不应该影响您的代码,但您在某些属性上缺少引号。 -
@Jesse arid 等是 Web 应用程序使用的自定义属性。如果有帮助,网络应用是 BMC Remedy。
-
@user619818 是否要在
arvfframe属性内的标记之外构造一个iframe?然后访问其中的子对象? -
@Jesse,我可以访问父 iframe(包含子) - 但我似乎无法访问里面的子对象。不幸的是,做模型很困难。
标签: javascript iframe