文件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>