Error while fetching elements of an IFrame inside

2019-07-22 14:14发布

问题:

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++; }

回答1:

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



回答2:

not sure why you did application="no" you should do application="yes" to enable the iframe and parent hta window to communicate and allow your hta to work with the iframe dom. however, that is from my experience with HTAs while working with IE6/7 and that was a long time ago

see more at msdn:

https://msdn.microsoft.com/en-us/library/ms536496(v=vs.85).aspx#Security