我正在尝试使用HTA自动执行表单填充的重复任务。我正在将网页打开到IFrame中。第一页是登录页面。我可以很容易地访问该页面的用户名和密码元素(IFrame中显示),因此可以通过点击HTA中的按钮来进行自动登录。但现在,下一页包含一个文本框,我需要填写然后再次单击一个按钮。现在,我在HTA中有一个按钮。当我点击这个按钮时,我希望文本框应该填入我提供的值。但是相反,我得到这个错误,无法设置null引用的属性'值'。在使用警报显示此对象时,它显示'null'。我没有得到,为什么我能够引用登录页面上的元素,为什么不在内部页面上。IFrame对象从包含IFrame的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按钮用于填充某些文本框。 不工作精细。
它不仅与这个文本框,我也有这个页面的其他elemts相同的问题。
PS:它是一个Peoplesoft Intranet网站。
@ Darryls99那是伟大的,它的工作精美。我没有意识到Peoplesoft本身就包含在IFrame中的事实。但是,我需要知道一件事,关于iframe,“ptifrmtgtframe”,这是所有页面使用的genric iFrame吗?或不同的页面显示在不同的iframe中?我在哪里可以得到这些信息。谢谢:-) –
简短回答是,iframe在PeopleSoft AFAIK中一直使用。长答案:通过更改网址并根据内容类型,iframe可能存在也可能不存在。在URL中,照顾服务器名称,如果将其从psp更改为psc,则只会获得iframe中的内容。 (没有导航)。此外,还有其他类型的PeopleSoft内容可能会或可能不会在iframe中(weblibcs,主页,导航等)。如果通过使用内置在浏览器中的开发人员工具查看页面来找到iFrame的名称。 – Darryls99
谢谢@ Darryls99。但是,如何处理显示为浮动页面的页面,例如Process Schedular Request页面,我们在这里选择要运行的进程和服务器。它也是一个IFrame?如何引用其元素。道歉,如果我有八卦,可以提出一个新的问题,如果需要的话。 :-) –