Link to home
Start Free TrialLog in
Avatar of Mykal73
Mykal73

asked on

Javascript Error 80020101

Ok, I'm at a loss with this. I have a program which automates the download of some data from a website. The download goes fine, but when I try to "click" the logout button with code I keep getting errors. To make it really weird, if I don't look up any data I can get the logout button to work by using the following code:

            Try
                retval = wb.Document.parentwindow.execscript("ProcessAppl('https://aws.aws.neteps.com/nssmm/entry.do','Signoff')", "Javascript")
            Catch
                retval = wb.Document.parentwindow.execscript("ProcessAppl('https://aws.aws.neteps.com/nssmm/entry.do','AWSmenu')", "Javascript")
            Finally

                retval = wb.Document.parentwindow.execscript("ProcessAppl('https://aws.aws.neteps.com/nssmm/entry.do','Signoff')", "Javascript")


            End Try

Basically, I pass the command I want, it throws an error, I purposely pass a bad command, which of course throws an error, then I pass the original command which now works.

I was happy with this method because it worked until I discovered that when I put all the pieces together, (ie, automate login, get the data, logout) this method no longer works even though the source code isn't changing. I can automate logging in, and log out via code as long as I don't get data. Oh, I don't know if it will help, but the browser I'm doing this with is IE 6, and I can't upgrade. Also, I have checked to see if there is an issue with frames, but the count comes back 0.  Does anyone have any idea what I'm doing wrong or how I can get this to work?

Here's some of the source code of the webpage
<SCRIPT language="JavaScript">

function crumbAddToPost( pair ) {
 var equalPos = pair.indexOf("=");
 var name = pair.substring(0, equalPos);
 var value = pair.substring( equalPos + 1 , pair.length );
 
  name = unescape( name );
  value = unescape( value );
 
 formHtml = "<input type=hidden name=\"" +
   name + "\" value=\"" +
   value +
   "\">";
 return formHtml;
}

function crumbPost( getUrl ) {

 var crumbForm = document.getElementById( "crumbForm" );
 
 if ( crumbForm == null || getUrl.length < 2 ) return;
  var formHtml = "";
 var tokenEnd = getUrl.indexOf("%%%%");
 
 if ( tokenEnd > 0 ) {
  crumbForm.action = getUrl.substring(0,tokenEnd);
  crumbForm.method = "POST";
  tokenEnd = tokenEnd + 4;
   var stringBreak = getUrl.indexOf("%%%%", tokenEnd );
 
  while( stringBreak != -1 && getUrl.length > tokenEnd ) {
   formHtml = formHtml + crumbAddToPost( getUrl.substring( tokenEnd, stringBreak ) );
   tokenEnd = stringBreak + 4;
   stringBreak = getUrl.indexOf("%%%%",tokenEnd);
  }
 
  if ( stringBreak == -1 && getUrl.length > tokenEnd ) {
   formHtml = formHtml + crumbAddToPost( getUrl.substring( tokenEnd, getUrl.length ) );
  }
 
  crumbForm.innerHTML = formHtml;
  crumbForm.submit();
 }
}

function getCookieDomain() {
 var hostname = window.location.hostname;
 var domain = "";
 var dotpos = hostname.lastIndexOf('.');
 if ( dotpos >= 0 ) {
   domain = hostname.substring(dotpos);
   hostname = hostname.substring(0, dotpos);
   dotpos = hostname.lastIndexOf('.');
   if ( dotpos >=0 ) {
     domain = hostname.substring(dotpos) + domain;
     return ";domain=" + domain;
   }
 }
 return "";
}

function smartCrumbBuild () {
 var crumb = document.getElementById("smartCrumbValue");
 if ( crumb != null ) {
  var value= crumb.innerHTML;
  if ( value.length > 7 ) {
 var cookie_value = 'smartCrumbCookie' + '="' + value.substring(4,value.length - 3)+ '";path=/'+getCookieDomain();
   document.cookie = cookie_value;
  }
 }
}


function smartCrumbOver( linkObject ) {
 linkObject.className = "smartLinkOver";
}


function smartCrumbOut( linkObject ) {
 linkObject.className = "smartLink";
}
</SCRIPT>









<script language="JavaScript"  type="text/javascript">
        var commonresourcesurl="/nss";
</script>
<script language="JavaScript" type="text/javascript" src="/nss/scripts/main-collate.js"></script>
<script language="JavaScript" type="text/javascript">
        window.onbeforeunload = confirmExit; //used to allow confirmation when leaving changed & unsubmitted forms. confirmExit() is defined in main-collate.js.
        //Application Menu
        var menuContents= Array();
        menuContents[0] = '<tr valign="top"><td class="main-menu-links"><span style="cursor:hand;" onMouseOver="menuLinkOver(this)" onMouseOut="menuLinkOut(this)" onClick="goToUrl(document.setUrl, \'NSSPAR\', \'/nsspar/index.do\');"><font size="1">Participant Management<\/font><\/span><\/td><\/tr><tr valign="top"><td class="main-menu-links"><span style="cursor:hand;" onMouseOver="menuLinkOver(this)" onMouseOut="menuLinkOut(this)" onClick="goToUrl(document.setUrl, \'AWS_TRANS_SUM\', \'/nsstrsum/LaunchApplet.jsp\');"><font size="1">Real-Time Transaction Summary<\/font><\/span><\/td><\/tr><tr valign="top"><td class="main-menu-links"><span style="cursor:hand;" onMouseOver="menuLinkOver(this)" onMouseOut="menuLinkOut(this)" onClick="goToUrl(document.setUrl, \'CMA_APPL\', \'/nsscma/index.jsp\');"><font size="1">Card Management &amp; Authorization<\/font><\/span><\/td><\/tr><tr valign="top"><td class="main-menu-links"><span style="cursor:hand;" onMouseOver="menuLinkOver(this)" onMouseOut="menuLinkOut(this)" onClick="goToUrl(document.setUrl, \'SS_TRAN\', \'/nsstr/startPage.do\');"><font size="1">Transaction Research<\/font><\/span><\/td><\/tr>'
                + '<tr valign="top"><td class="main-menu-links">------------------------------<\/td><\/tr>'
                + '<tr valign="top"><td class="main-menu-links"><span style="cursor:hand;" onMouseOver="menuLinkOver(this)" onMouseOut="menuLinkOut(this)" onClick="goToUrl(document.setUrl, \'AWSmenu\', \'/nssmm/entry.do\');"><font size="1">Home<\/font><\/span><\/td><\/tr>'
                + '<tr valign="top"><td class="main-menu-links"><span style="cursor:hand;" onMouseOver="menuLinkOver(this)" onMouseOut="menuLinkOut(this)" onClick="goToUrl(document.setUrl, \'Signoff\', \'/nssmm/entry.do\');"><font size="1">Logout<\/font><\/span><\/td><\/tr>';
</script>

ASKER CERTIFIED SOLUTION
Avatar of Mykal73
Mykal73

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial