在HTA中获取IFrame元素时出错 [英] Error while fetching elements of an IFrame inside HTA

查看:82
本文介绍了在HTA中获取IFrame元素时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在努力实现Intranet网站的自动化.为此,我们将HTA与Java脚本一起使用.与其在浏览器中打开网站,不如使用HTA本身的Iframe(因为浏览器安全设置禁止我们执行任何操作).能够登录到该网站,但是,从此之后的每一步之后,我们都会显示此错误消息,提示无法获取未定义或空引用的属性'children'." 在此下方还提供了一个 URL:http://*******.. *:8888/cs/domainname/cache/PT_HNAV_JS_MIN_1.js

更具体地说,它是一个Peoplesoft网站.有人可以阐明如何解决这个问题吗?

下面是HTML代码:

    <html>
    <head>
    <HTA:APPLICATION
         APPLICATIONNAME="HTA"
         SYSMENU="YES"
     >

    <meta http-equiv="x-ua-compatible" content="ie=9">
    <title>HTA</title>

    <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='@@';
    passwd.value='@@';
    form.submit();
    }

    </script>
    </head>
     <body> 
    <form class="form" name="form">
        <input class="links" type="button"  value="Project Plan" onclick="Start();" /> 
    </form> 
        <iframe application="no" src="http://****.**.****:8888/psp/sitename/?cmd=login&languageCd=ENG&" width="600" height="600" id="iframeid"> 

    </body> 
    </html>

我可以在下面的相关js文件中找到子项的首次出现:

this.fakeBCReqWC = false;  
var bchidden = 0; 
if(eBC.childNodes.length == 0)     bchidden=1; 
this.bcScrollUl = ptUtil.id(pthNav.bcScrollId); 
if    (eBC.children[1])
     var clickedURL = eBC.children[1].firstChild.href; 
var nChildren = 0;     
if     (this.bcScrollUl)
     nChildren = this.bcScrollUl.children.length;  
var nIdx = 0;  
if        (this.fakeBCSetN) {
var isBCpath = false; 
var fakechildindex = 0; 
var i = 0; 
while(nIdx <     nChildren) {
     var child = this.bcScrollUl.children[nIdx]; 
if(child.id && child.id.indexOf    ("FAKE") != -1 && child.firstChild &&     child.firstChild.href     == clickedURL) {
     isBCpath = true; fakechildindex = nIdx;  break; }
     nIdx++; }

解决方案

更改x-ua兼容以指向IE 11可以解决此问题.之前它指向IE9.

We are trying to acheive automation of an Intranet site. We are using HTA along with java script for this purpose. Instead of opening the site in browser, we are using an Iframe, withing the HTA itself, for it (Since the browser security settings bars us from doing anything). Eare able to login to the website,however, after every step from then we get this error message, saying "Unable to get property 'children' of undefined or null reference." below this it also gives a URL : http://*******..*:8888/cs/domainname/cache/PT_HNAV_JS_MIN_1.js

To be more specific, it is a peoplesoft site. Can someone shed light on how to resolve this ?

Below is the HTML code :

    <html>
    <head>
    <HTA:APPLICATION
         APPLICATIONNAME="HTA"
         SYSMENU="YES"
     >

    <meta http-equiv="x-ua-compatible" content="ie=9">
    <title>HTA</title>

    <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='@@';
    passwd.value='@@';
    form.submit();
    }

    </script>
    </head>
     <body> 
    <form class="form" name="form">
        <input class="links" type="button"  value="Project Plan" onclick="Start();" /> 
    </form> 
        <iframe application="no" src="http://****.**.****:8888/psp/sitename/?cmd=login&languageCd=ENG&" width="600" height="600" id="iframeid"> 

    </body> 
    </html>

I could find the first occurance of children in the relevant js file is below :

this.fakeBCReqWC = false;  
var bchidden = 0; 
if(eBC.childNodes.length == 0)     bchidden=1; 
this.bcScrollUl = ptUtil.id(pthNav.bcScrollId); 
if    (eBC.children[1])
     var clickedURL = eBC.children[1].firstChild.href; 
var nChildren = 0;     
if     (this.bcScrollUl)
     nChildren = this.bcScrollUl.children.length;  
var nIdx = 0;  
if        (this.fakeBCSetN) {
var isBCpath = false; 
var fakechildindex = 0; 
var i = 0; 
while(nIdx <     nChildren) {
     var child = this.bcScrollUl.children[nIdx]; 
if(child.id && child.id.indexOf    ("FAKE") != -1 && child.firstChild &&     child.firstChild.href     == clickedURL) {
     isBCpath = true; fakechildindex = nIdx;  break; }
     nIdx++; }

解决方案

Changing x-ua-compatible to point to IE 11 resolved the issue. Earlier it pointed to IE9.

这篇关于在HTA中获取IFrame元素时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆