Synchronizing the screen to the script
Before you perform any action on the display screen, you must ensure that the current screen is the expected screen. Call the WaitForFieldData method to determine this.
WaitForFieldData must be used to ensure that the script stays synchronized to the screen. See the sample script below for usage details.
Sample script
The following sample script performs an auto login and is called by the <body> OnLoad event.
<script type="text/javascript" language="jscript">

// this function is called by body onload
function OnLoad() {
    
    autoLogin()
}

// this function enters the login info on the Sign On screen 
// and hits 'Enter'
function autoLogin() {

    // example of how to test for existence of HFDSP object
    if (typeof HFDSP == "undefined") {
        alert("HFDSP is undefined")
    }
    
    // example of how to test for existence of HFDSP object
    if (HFDSP==null) {
        alert("HFDSP is null")
    }

    // ALWAYS use WaitForFieldData to make sure you are on the
    // correct screen before proceeding
    if (HFDSP.WaitForFieldData("Sign On", 1, 36, 42, 10000)) {
            // we are now on the 'Sign On' screen
            HFDSP.PutField(6, 53, "aUser")
            HFDSP.PutField(7, 53, "secretPassword")
            HFDSP.PushKeyStream("<ENTER>")
	  } else {
	      alert("Didn't find the Sign On screen")
	  }
}

</script>