archivo demo.html
<! Doctype html público -// w3c // dtd html 4.0 transitional // en>
<html>
<Evista>
<meta name = generador content = Microsoft Visual Studio 7.0>
<title> </title>
</ablo>
<Script Language = JavaScript>
función onload ()
{
var str = window.dialogarguments;
if (str! = indefinido)
{
var arr = str.split (-);
if (arr.length == 2)
{
frMMain.txtname.Value = arr [0];
frMMain.txtamount.value = arr [1];
}
}
}
función onSubMit ()
{
if (frMMain.txtname.value == || frMMain.txtamount.value ==)
{
alerta (都要填);
devolver falso;
}
else if (! isdigit (frMMain.txtamount.value))
{
alerta (cantidad 必须是数字);
frMMain.txtamount.focus ();
frMMain.txtamount.select ();
devolver falso;
}
demás
{
var odemo = new Demo (frMMain.txtname.Value, frMMain.txtamount.value);
Window.ReturnValue = Odemo;
window.close ();
}
}
Demostración de funciones (nombre, cantidad)
{
this.name = name;
this.amount = cantidad;
this.ToString = function ()
{
devuelve this.name + - + this.amount;
};
this.FromString = function (str)
{
var arr = str.split (-);
if (str ==)
{
this.name =;
this.amount = 0;
}
más if (arr.length == 2)
{
this.name = arr [0];
this.amount = arr [1];
}
demás
{
alerta (格式错误);
devolver falso;
}
};
}
función isdigit (str)
{
para (var i = 0; i <str.length; i ++)
{
var ch = str.charat (i);
if (ch <'0' || ch> '9')
{
devolver falso;
}
}
devolver verdadero;
}
</script>
<Body onload = onload ()>
<Nombre de formulario = FrMMain>
<ancho de tabla = 200 align = Center>
<tr>
<td width = 50> nombre: </td>
<TD> <input type = text name = txtname size = 10> </td>
</tr>
<tr>
<td width = 50> cantidad: </td>
<TD> <input type = text name = txtamount size = 10> </td>
</tr>
<tr>
<td align = center> <input type = button onClick = onSubMit () value = 确定> </td>
</tr>
</table>
</form>
</body>
</html>