Windows XP中的批处理HTA混合脚本错误

时间:2019-06-13 11:50:49

标签: html batch-file hta

我写了一批HTA混合脚本。我用它来处理一些用户输入。 它适用于Windows 7和10。 在Windows XP中,我总是收到错误消息:

  

document.getElementById;为空或没有对象

也许有人有主意,或者可以告诉我我的错误在哪里?

以下是该脚本的一个小的可执行代码段:

<!-- :: Batch section
@echo off
title Meldung
setlocal enableextensions disabledelayedexpansion

set message=""
set lastname=Dude
set firstname=Der
set userc=1234

:goon
for /F "tokens=1" %%a in ('mshta.exe "%~F0" test2 %userc% %lastname% %firstname% %message%') do (
        set "button=%%a"
    )
if "%button%" == "2" goto :end
echo %lastname%%time% >> logtext.txt
set message="successfully"
goto :goon

:end
goto :eof 
-->
<HTML>
<HEAD>
<HTA:APPLICATION SCROLL="no" SYSMENU="no" ID="thisHTAID" >
<TITLE>Try</TITLE>
<SCRIPT language="JavaScript">
    window.resizeTo(450,300);
    window.moveTo(0,0);

    // function handling test2 hta output
    function myButton( selectedb ){
        new ActiveXObject("Scripting.FileSystemObject")
            .GetStandardStream(1)
            .WriteLine( selectedb );
        window.close()
    };

    function parseCommandline(commandLine) {
        var rx = /"[^"]+"\s*?|\S+\s*?/g;
        var args = [];
        var match;
        while (match = rx.exec(commandLine)) {
            if (match[0].charAt(0) === '"') {
                args.push(match[0].substring(1, match[0].length - 1));
            } else {
                args.push(match[0]);
            }
        }
        return args;
    }

    // on window load select what div to show depending on command line 
        window.onload = function(){
        var commandLine = thisHTAID.commandLine;
        var args = parseCommandline(commandLine);
        var test = args[1];
        var testa = args[2];
        var testb = args[3];
        var testc = args[4];
        var testd = args[5];
        document.getElementById("number").innerHTML=testa;
        document.getElementById("name").innerHTML=testb;
        document.getElementById("firstname").innerHTML=testc;
        document.getElementById("message").innerHTML=testd;
        document.getElementById( test ).style.display='block';
    };

</SCRIPT>
<style type="text/css">
.auto-style1 {
    text-align: center;
    font-family: Georgia, "Times New Roman", Times, serif;
}
.auto-style3 {
    color: #008000;
    text-align: center;
    font-size: 12pt;
    font-family: Georgia, "Times New Roman", Times, serif;
}       
</style>
</HEAD>
<BODY>
    <div id="test2" style='display:none'>
        <h3 class="auto-style1">Process</h3>
        <table style="width: 100%" >
            <tr>
                <td style="width: 150px"><strong>Number:</strong></td>
                <td id="number"></td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>         
            </tr>
            <tr>
                <td><strong>Name:</strong></td>
                <td id="name"></td>
            </tr>
            <tr>
                <td><strong>Firstname:</strong></td>
                <td id="firstname"></td>
            </tr>
        </table>
        <p></p>
        <button onclick="myButton(1)" style="width: 90px; height: 40px; margin-right: 20px; font-size: 9pt; font-family: Georgia, "Times New Roman", Times, serif; "><b>Write</b></button>
        <button onclick="myButton(2)" style="width: 90px; height: 40px; margin-right: 10px; font-size: 9pt; font-family: Georgia, "Times New Roman", Times, serif; "><b>End</b></button>
        <p></p>
        <p class="auto-style3" id="message"></p>
    </div>  
</BODY>
</HTML>

0 个答案:

没有答案