ActiveX控件在客户端的引用:
下面是一个将用户信息写在其本地文件的一个例子。
<HTML>
<H1> MODEL APPLICATION </H1><p>
<HR><center><P>
<OBJECT
classid="clsid:EAECC9E4-24A2-45B5-B899-9D0C43EFD0A0"
codebase="http://172.18.93.234/ocx/ABCBank.cab#version=1,0,3,5"
id=ABCBank
width=0
height=0
align=center
hspace=0
vspace=0
>
</OBJECT>
<table width="300" bgcolor="#000000" >
<tr>
<td>
<font color="#FFFFFF">
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
姓名:<input name='NameEdit'><br>
出生年月:<input name='BirthEdit'><br>
<input type='button' name='AddBtn' value='新增'>
<input type='button' name='DelBtn' value='删除'>
<input type='button' name='ClearBtn' value='清空'><br>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
</font>
</td>
</tr>
</table>
<!--脚本-->
<script Language=VBScript>
dim ErrorCode
dim TradeCount, I
dim Msgs
'On Error GoTo ErrHandler
'ABCBank.SayHello "程序"
'ABCBank.Add "abc", CStr(now), ErrorCode
ABCBank.Count "abc", TradeCount, ErrorCode
if ErrorCode <> 0 then
TradeCount = 0
end if
if TradeCount > 0 then
Document.Write "<select>"
for I = 0 to TradeCount - 1
ABCBank.Read "abc", I, Msgs, ErrorCode
Document.write "<option>" & Msgs & "</option>"
next
Document.Write "</select><br>"
for I = 0 to TradeCount - 1
ABCBank.Read "abc", I, Msgs, ErrorCode
Document.Write "<input type='text' name='E1' value='" & Msgs & "'>"
Document.Write "<input type='checkbox' name='C1' value='ON'>" & Msgs & "<br>"
'MsgBox Msgs
next
end if
'ErrHandler: ' Error-handling routine
'MsgBox "Error " & Err & " at line number" &Erl
'Resume Next ' Resume the procedure.
' 新增
sub AddBtn_onclick
dim i_Op
dim s_Op
i_Op = 0
s_Op = ""
if NameEdit.Value = "" then
s_Op = s_Op & "姓名不允许为空!" & chr(13) & chr(10)
i_Op = 1
end if
if BirthEdit.Value = "" then
s_Op = s_Op & "出生年月不允许为空!" & chr(13) & chr(10)
i_Op = 2
end if
if i_Op = 0 then
ABCBank.Add "abc", NameEdit.Value + BirthEdit.Value, ErrorCode
window.history.go(0)
else
MsgBox s_Op
end if
end sub
' 删除
sub DelBtn_onclick
AbcBank.Delete "abc", NameEdit.Value + BirthEdit.Value, ErrorCode
select case ErrorCode
case 0
MsgBox "删除成功!"
window.history.go(0)
case -1 MsgBox "临时交易文件不存在!"
case -2 MsgBox "临时交易中不存在指定的报文!"
end select
end sub
' 清空
sub ClearBtn_onclick
dim i_ClearFlag
i_ClearFlag = 0
ABCBank.Count "abc", TradeCount, ErrorCode
if ErrorCode <> 0 then
TradeCount = 0
end if
for I = 0 to TradeCount - 1
ABCBank.Read "abc", I, Msgs, ErrorCode
ABCBank.Delete "abc", Msgs, ErrorCode
if ErrorCode <> 0 then
i_ClearFlag = i_ClearFlag + 1
end if
next
if i_ClearFlag = 0 then
MsgBox "清空操作成功!"
window.history.go(0)
else
MsgBox "清空操作失败,可能只清空某些记录!"
end if
end sub
</script>
</HTML>