当从包含IFrame的HTA中引用IFrame对象时返回null
IFrame object returning null when referenced from HTA containing the IFrame
我正在尝试使用HTA自动完成表单填写的重复任务。我正在打开网页到一个IFrame。第一页是登录页。我能够轻松访问该页的用户名和密码元素(显示在IFrame中),因此能够通过单击HTA中的按钮自动登录。但是现在,下一页包含一个文本框,我需要填充,然后再次单击按钮。现在,我在HTA中有一个按钮。当我单击此按钮时,我希望文本框应该填充我所提供的值。但相反,我得到这个错误,无法设置空引用的属性"值"。在使用警告显示此对象时,它显示'null'。我没有得到,为什么我能够引用登录页面上的元素,为什么不在内页。
下面是我的代码:<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="HTA"
SYSMENU="YES"
NAVIGABLE="YES"
>
<meta http-equiv="x-ua-compatible" content="ie=11">
<title>HTA</title>
<script type="text/javascript">
window.resizeTo(700,700);
</script>
<script type="text/javascript" >
function Start() {
var iframePage = document.getElementById("iframeid").contentDocument;
var userId = iframePage.getElementById("userid");
var passwd = iframePage.getElementById("pwd");
var form = iframePage.getElementById("login");
userId.value='uu';
passwd.value='pp';
form.submit();
}
function Show() {
document.getElementById("iframe").style.display = "block";
}
function FillRncntl() {
var iframePages = document.getElementById("iframeid").contentDocument;;
var runcntl = iframePages.getElementById("PRCSMULTI");
runcntl.value='test';
}
</script>
</head>
<body>
<form class="form" name="form">
<input class="links" type="button" value="Show PIA" onclick="Show();" />
<input class="links" type="button" value="Login" onclick="Start();" />
<input class="links" type="button" value="Enter Runcontrol" onclick="FillRncntl();" />
</form>
<br>
<div class="iframe" id="iframe" style="display:none">
<iframe application="no" src="www.xyz.com" width="600" height="600" id="iframeid">
</div>
</body>
</html>
-Show PIA按钮显示登录页面。工作正常。
-Login按钮用于自动登录。工作正常。
-Enter Runcntl按钮用于填充某些文本框。不能正常工作。
这不仅仅是与这个文本框,我有同样的问题与其他元素从这个页面以及。
PS:这是Peoplesoft的内网网站。
PeopleSoft内容包含在iFrame本身中,因此您需要获取targetContent iFrame并在其中搜索元素。
初始PeopleSoft登录页面不显示在iFrame中。
我更改了最后一个元素ID,以便这将在组件上工作:PeopleTools->Process Scheduler->System Process Requests
function FillRncntl() {
var iframePages = document.getElementById("iframeid").contentDocument;
var targetContent = iframePages.getElementById("ptifrmtgtframe").contentDocument;
var runcntl = targetContent.getElementById("PRCSRUNCNTL_RUN_CNTL_ID");
runcntl.value='test';
}
相关文章:
- 动态(重新)创建iframe内容不会重置Chrome中的JS对象
- 将 JSON 对象发布到 iFrame
- 如何使用jquery操作iframe对象
- 重用iframe中的jQuery对象
- 如何从主框架获取对在iframe上创建的对象的引用
- 将 Javascript 对象传递给 HTML iframe(作为对象)
- 在嵌入式站点上使用javascript?(iframe,对象)
- IE9 在 iframe 中打印 PDF 时出现“无效调用对象”
- 从 iframe 访问父级中的 JavaScript 对象
- 访问父 DOM 中的 iframe 窗口对象
- 如何将 Jquery 对象从父 iframe 注入到嵌入式 iframe
- 创建 YT.通过传递 DOM 对象,在 HTML 中来自 iframe 的播放器对象
- 正在检测iframe对象中的src/location更改
- 当从包含IFrame的HTA中引用IFrame对象时返回null
- 如何嵌入translate.google.com没有iframe/对象(x - frame选项是SAMEORIGIN)
- 如何覆盖图像和链接路径在iframe对象
- 如何获得iframe对象的原点
- 如何访问全局iframe对象
- 访问iframe对象.在IE8中的原型
- 设置iframe对象的z轴顺序