文件demo.html
<!Doctype HTML公共 - // W3C // DTD HTML 4.0过渡// en>
<html>
<头>
<meta名称=发电机内容= Microsoft Visual Studio 7.0>
<title> </title>
</head>
<脚本语言= JavaScript>
功能onload()
{
var str = window.dialogarguments;
如果(str!=未定义)
{
var arr = str.split( - );
if(arr.length == 2)
{
frmmain.txtName.value = arr [0];
frmmain.txtamount.value = arr [1];
}
}
}
函数onsubmit()
{
if(frmmain.txtname.value == || frmmain.txtamount.value ==)
{
警报(都要填);
返回false;
}
否则if(!
{
警报(金额必须是数字);
frmmain.txtamount.focus();
frmmain.txtamount.Select();
返回false;
}
别的
{
var odemo = new demo(frmmain.txtName.value,frmmain.txtamount.value);
window.turnvalue = odemo;
window.close();
}
}
功能演示(名称,金额)
{
this.name = name;
this.amount =量;
this.tostring = function()
{
返回this.name + - + this.amount;
};
this.fromstring =函数(str)
{
var arr = str.split( - );
如果(str ==)
{
this.name =;
this.amount = 0;
}
否则(arr.length == 2)
{
this.name = arr [0];
this.amount = arr [1];
}
别的
{
警报(格式错误);
返回false;
}
};
}
功能iSdigit(str)
{
for(var i = 0; i <str.length; i ++)
{
var ch = str.charat(i);
if(ch <'0'|| ch>'9')
{
返回false;
}
}
返回true;
}
</script>
<body onload = onload()>
<形式名称= frmmain>
<table width = 200 align =中心>
<tr>
<td width = 50>名称:</td>
<td> <input type = text Name = txtName size = 10> </td>
</tr>
<tr>
<td width = 50>金额:</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>