Datei Demo.html
<! docType html public -// w3c // dtd html 4.0 transitional // en>
<html>
<kopf>
<meta name = Generator content = Microsoft Visual Studio 7.0>
<title> </title>
</head>
<script Language = JavaScript>
Funktion onload ()
{
var str = fenster.dialogargumente;
if (str! = undefiniert)
{
var arr = str.split (-);
if (arr.length == 2)
{
frmmain.txtName.value = arr [0];
frmmain.txtAmount.Value = arr [1];
}
}
}
Funktion onSubmit ()
{
if (frmmain.txtName.value == || frmmain.txtAmount.Value ==)
{
Alarm (都要填);
false zurückgeben;
}
sonst wenn (! isDigit (frmmain.txtAmount.Value))
{
Alarm (Betrag 必须是数字);
frmmain.txtamount.focus ();
frmmain.txtamount.select ();
false zurückgeben;
}
anders
{
var odemo = new Demo (frmmain.txtName.Value, frmmain.txtAmount.Value);
Fenster.ReturnValue = odemo;
Fenster.CLOSE ();
}
}
Funktion Demo (Name, Betrag)
{
this.name = name;
this.amount = Menge;
this.toString = function ()
{
zurück this.name + - + this.amount;
};
this.fromstring = function (str)
{
var arr = str.split (-);
if (str ==)
{
this.name =;
this.amount = 0;
}
sonst wenn (arr.length == 2)
{
this.name = arr [0];
this.amount = arr [1];
}
anders
{
Alarm (格式错误);
false zurückgeben;
}
};
}
Funktion isDigit (STR)
{
für (var i = 0; i <str.length; i ++)
{
var ch = str.charat (i);
if (ch <'0' || ch> '9')
{
false zurückgeben;
}
}
zurückkehren;
}
</script>
<body onload = onload ()>
<Formular name = frmmain>
<Tabellenbreite = 200 Align = Center>
<tr>
<td width = 50> Name: </td>
<td> <Eingabe type = textname = txtName size = 10> </td>
</tr>
<tr>
<td width = 50> Menge: </td>
<td> <Eingabe type = Textname = txtAmount size = 10> </td>
</tr>
<tr>
<td align = center> <Eingabe type = button onclick = ondsubmit () value = 确定> </td>
</tr>
</table>
</form>
</body>
</html>