首页 > 办公 > Dreamweaver > 正文

在网页调用 WINDOWS 控件两例-Dreamweaver教程

2024-09-12 12:29:51
字体:
来源:转载
供稿:网友

一、这个是netmting的例子

<html>
<head>
<title>ocx</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<script language="javascript">
var flag=true
function showall(){
alist = new array();
newocx();
list1.value = "";
list2.value = "";
list1.value = ocxtype.outerhtml;
j = 0;
for (i in ocxtype)
{
alist[j] = i;
j ;
}
for (i = 0; i < alist.length; i )
for (j = (alist.length-1); j > 0; j--)
{
if (alist[j] < alist[j-1])
{
temps = alist[j];
alist[j] = alist[j-1];
alist[j-1] = temps;
}
}
for (i = 0; i < alist.length; i )
list2.value = alist[i] "/n";
alert("共有 " alist.length " 个属性方法")
}
function newocx()
{
ocxfield.innerhtml = "<object id='ocxtype' width='0px' height='0px'"
"classid='clsid:" ocxid.value "'></object>";
}
</script>
</head>

<body bgcolor="#ffffff" text="#000000">

<div align="center">
<p>classid
<input type="text" id="ocxid" style="width:400" value="f3a614dc-abe0-11d2-a441-00c04f795683" onchange="jscript:flag=true">
<input type="button" id="look" value="查看" onclick="showall()">
</p>
<table width="75%" border="1">
<tr>
<td height="24">
<div align="center">html中的写法</div>
</td>
<td height="24">
<div align="center">ocx中的属性事件</div>
</td>
</tr>
<tr>
<td>
<textarea id="list1" style="width: 500px; height: 400px;" readonly></textarea>
</td>
<td>
<textarea id="list2" style="width:250px; height:400px;" readonly></textarea>
</td>
</tr>
</table>
</div>
<div id="ocxfield">
</div>
</body>
</html>

二、

<script language="javascript">
function showmessenger() {
if (messengerui.object != null) {
var msgrwindow
if (messengerui.mystatus == 2) {
msgrwindow = messengerui.window;
msgrwindow.show();
}
else
messengerui.signin(0,"","");
}
}

function showelement(element) {
element.style.display="";
document.msn.offline.value="on";
}
function hideelement(element) {
//rowshow.style.visibility="hidden";
element.style.display="none";
document.msn.offline.value="off";
}

function showhide(element) {
if (document.msn.offline.value=="on") {
hideelement(element);
}
else {
showelement(element);
}

}
</script>
<style type="text/css"> |||
<!--
.small { font-size: 11px; font-family: verdana, arial, helvetica, sans-serif}
body { font-family: verdana, arial, helvetica, sans-serif}
a { color:#3d55c4 ; text-decoration: none}
a:link { color:#3d55c4 ; text-decoration: none}
a:hover { color:#000000 ; text-decoration: none}
-->
</style>
</head>

<body bgcolor="#ffffff" text="#000000" vlink="##3d55c4" onclick="(muser.innerhtml)">
<table cellpadding="1" cellspacing="1" bgcolor="#3d55c4" width="150" id="abc">
<script language="vbscript" id="mcvbs">
' this script is loosely based on the original script from microsoft.
' various flags and such for god-knows what...
dim a_
a_=false
dim b_,c_,d_
b_=false
c_=false
d_=false
dim e_,f_,g_
e_=false
f_=false
g_=3000 ' ooohhh! i know what this is! this is the amount of milliseconds for refresh
dim h_(),i_ ' h_() is an object array of users. this is also the cache
i_=0
' variables for different links to different images representing state in messenger... i think
dim j_,k_,l_,m_,n_,o_,p_,offl
j_="<object classid="""&"clsid:fb7199ab-79bf-11d2-8d94-0000f875c541"""&" codetype=application/x-oleobject id=msgrapp width=0 height=0></object>"
k_="<font class=""small"">"
m_="<img align=absbottom width=16 height=17 border=0 src="
l_="<br><b> <a href=""vbscript:op(-1)"" class=""color""><img src='msn_icons/msn_ppl.gif' border='0' alt=''>"&" sign in now... "&"</a></b>"
n_=m_&"msn_icons/online1.gif"&" alt="""&"online"&""">"
o_=m_&"msn_icons/busy1.gif"&" alt="""&"busy"&""">"
p_=m_&"msn_icons/idle1.gif"&" alt="""&"away"&""">"
'added by jh
offl = m_&"msn_icons/offline1.gif"&" alt="""&"offline"&""">"
m_="<img align=absbottom width=16 height=17 border=0 src="
dim q_
q_=false
dim ttl
ttl=0
' added arrays for online and offline contacts
dim ona() ' online contacts
dim offa() ' offline contacts
' counters for amount of online and offline
dim onctr
onctr=0
dim offctr
offctr=0
' online/offline?

sub drawinitialstate
on error resume next
dim r_
r_=msgrobj.localstate
if err then
a_=false
else
a_=true
end if
err.clear
if a_=true then
document.all.getmsgr.style.display="none"
drawcontacts
else
document.all.getmsgr.style.display="block"
end if
end sub

function hasmsgrapp()
appload.innerhtml = j_
on error resume next
dim r_
set r_=msgrapp
if err.description="" then
hasmsgrapp=true
else
hasmsgrapp=false
end if
err.clear
end function

sub refreshmc()
if a_ then
if c_ then
d_=true
else
d_=false
drawcontacts
setrefreshtimer
end if
end if
end sub

sub setrefreshtimer()
if not c_ then
c_=true |||
settimeout "dorefresh",g_,"vbscript"
end if
end sub

sub dorefresh()
c_=false
if d_ then
refreshmc
end if
end sub

sub drawcontacts
'********************************************************************
' modified by jh
' drawcontacts:
'
on error resume next
' new list of contacts to iterate thru
' ctr for list loop
dim i
i = 0
' strings for output
dim z, zz
z=""
zz=""
' for div visibility
dim mu,mo,msgl,nonel,noton,onli
mu="none"
mo="none"
msgl="none"
nonel="none"
noton="block"
onli="block"
if e_ then
mcclearcache
end if
' the heart of the matter
if msgrobj.localstate and 2 then
'online
if not f_ then
mcloadcache
end if
if i_>0 then
for i = 0 to ttl
select case h_(i).state
case 1
offctr = offctr 1
case else
onctr = onctr 1
end select
next
redim ona(onctr)
redim offa(offctr)
onctr = 0
offctr = 0
' loop to get friendlynames of contacts and put them in their respective arrays
for i = 0 to ttl
if h_(i).state=1 then
set offa(offctr)=h_(i)
offctr = offctr 1
else
set ona(onctr) = h_(i)
onctr = onctr 1
end if
next
' sort online users
sortusers2 0,onctr-1,true
for i = 0 to onctr-1
dim onl
dim h
onl=""
h=""
h = " href='vbscript:op(" & i & ")'"
onl = fixname(ona(i).friendlyname,17)
z = z & "<a" & h & " class=""color"">" & getstateimage(ona(i).state) & "</a> " & "<a " & h & " title="""
z = z & "send an instant message to " & onl & "."
z = z & """ class=""color"">" & k_ & onl
z = z & "</font></a><br>"
next
' sort offline users
sortusers2 0,offctr-1,false
for i = 0 to offctr-1
dim ofn
ofn=""
ofn = fixname(offa(i).friendlyname,17)
zz = zz & getstateimage(offa(i).state) & " "
zz = zz & k_ & ofn & "<br>"
next
if onctr > 0 then
mu="block"
mo="block"
document.all.muser.innerhtml=z
document.all.moff.innerhtml=zz
else
mu="block"
mo="block"
document.all.muser.innerhtml="<font class=""small"">none</font>"
document.all.moff.innerhtml=zz
end if
else
nonel="block"
document.all.noneol.innerhtml=k_&"your contact list is empty. <br><a href=vbscript:op(-2) class=""color"">add contacts to your list.</a>"&"</font>"
end if
else
if msgrobj.localstate=256 or msgrobj.localstate=512 then
msgl="block"
noton="none"
onli="none"
b_ = true
document.all.statu.innerhtml = "<br> <img src='msn_icons/msn_ppl.gif' border='0' alt=''> <b>connecting...</b></div>"
else
msgl="block"
noton="none"
onli="none"
if not b_ then
document.all.statu.innerhtml = l_
end if
end if
end if
document.all.online.style.display=onli |||
document.all.muser.style.display=mu
document.all.notonline.style.display=noton
document.all.moff.style.display=mo
document.all.msgrlogon.style.display=msgl
document.all.noneol.style.display=nonel
end sub

sub mcclearcache
i_=0
erase h_
erase ona
erase offa
f_=false
e_=false
d_=true
end sub

sub mcloadcache
dim bb_

set bb_=msgrobj.list(0)

dim cb_
cb_=0
dim db_
db_=bb_.count
ttl=db_ -1
redim h_(db_)
for each u in bb_
set h_(cb_)=u
cb_=cb_ 1
next
i_=cb_
sortusers 0,i_-1
f_=true
end sub

' added by jh
' sorts online/offline users
sub sortusers2(eb_,fb_,ison)
dim gb_
if(ison) then
if fb_>eb_ then
gb_=ptnon(eb_,fb_)
sortusers2 eb_,gb_-1,true
sortusers2 gb_ 1,fb_,true
end if
else
if fb_>eb_ then
gb_=ptnoff(eb_,fb_)
sortusers2 eb_,gb_-1,false
sortusers2 gb_ 1,fb_,false
end if
end if
end sub

sub sortusers(eb_,fb_)
dim gb_
if fb_>eb_ then
gb_=ptn(eb_,fb_)
sortusers eb_,gb_-1
sortusers gb_ 1,fb_
end if
end sub

' added by jh
'
function ptnon(eb_,fb_)
dim hb_,tmp
randomize
hb_=int(rnd()mod(fb_-eb_ 1)) eb_
set tmp=ona(hb_)
set ona(hb_)=ona(eb_)
set ona(eb_)=tmp
dim a,b
a=eb_
b=fb_
while b>a
if strcomp(ona(b).friendlyname,tmp.friendlyname,1)>=0 then
b=b-1
else
set ona(a)=ona(b)
set ona(b)=ona(a 1)
set ona(a 1)=tmp
a=a 1
end if
wend
ptnon=a
end function

' added by jh
'
function ptnoff(eb_,fb_)
dim hb_,tmp
randomize
hb_=int(rnd()mod(fb_-eb_ 1)) eb_
set tmp=offa(hb_)
set offa(hb_)=offa(eb_)
set offa(eb_)=tmp
dim a,b
a=eb_
b=fb_
while b>a
if strcomp(offa(b).friendlyname,tmp.friendlyname,1)>=0 then
b=b-1
else
set offa(a)=offa(b)
set offa(b)=offa(a 1)
set offa(a 1)=tmp
a=a 1
end if
wend
ptnoff=a
end function

sub msgrobj_onlocalstatechangeresult(byval hr,byval mlocalstate,pservice)
if 0=hr and err.description="" and a_ then
if mlocalstate=256 or mlocalstate=512 then
b_=true
document.all.statu.innerhtml="signing in..."
elseif mlocalstate=1024 then
b_=true
document.all.statu.innerhtml="signing out..."
elseif mlocalstate=1 then
b_=true
document.all.statu.innerhtml=l_
end if
refreshmc
end if
end sub

sub msgrobj_onuserstatechanged(puser,byval mprevstate,pfenabledefault)
'if err.description="" then
mcclearcache
b_=false
refreshmc
'end if
end sub

sub msgrobj_onlistremoveresult(byval hr,byval mlist,byval puser)
if 0=hr and 0=mlist and err.description="" then
e_=true
refreshmc
end if
end sub

sub msgrobj_onlistaddresult(byval hr,byval mlist,byval puser)
if 0=hr and 0=mlist and err.description="" then
e_=true
refreshmc
end if |||
end sub

sub msgrobj_onlogonresult(byval hr,byval pservice)
if 0=hr and err.description="" then
mcclearcache
b_=false
refreshmc
else
mcclearcache
b_=false
refreshmc
end if
end sub

sub msgrobj_onlogoff()
mcclearcache
b_=false
refreshmc
end sub

sub msgrobj_onappshutdown()
refreshmc
end sub


' launches chat window for a given user, or
' launches the logon window, or simply brings up
' messenger to show all contacts.
function op(n)
if hasmsgrapp then
if n>=0 then
document.all.mctrack.src="p/6/"
on error resume next
msgrapp.launchimui ona(n)
elseif-1=n then
msgrapp.launchlogonui
else
msgrapp.visible=1
end if
end if
end function

function htmlesc(str)
str=replace(str,"&","&")
str=replace(str,"<","<")
htmlesc=replace(str,">",">")
end function

function fixname(s,max)
if len(s)>max then
s=left(s,max-2)&"..."
end if
fixname=htmlesc(s)
end function

function getstateimage(t)
select case t
case 1
getstateimage=offl 'offline
case 2
getstateimage=n_ 'online
case 10
getstateimage=o_ 'busy
case 14
getstateimage=p_ 'brb
case 18
getstateimage=p_ 'away
case 34
getstateimage=p_ 'away... as well.......
case 50
getstateimage=o_ 'on the phone
case 66
getstateimage=o_ 'out to lunch
end select
end function
</script>

<object id=msgrobj height=0 codetype=application/x-oleobject width=0
classid=clsid:f3a614dc-abe0-11d2-a441-00c04f795683>
<span style="display:none;"> </span>
</object>

<script language="vbscript" event="onreadystatechange" for="mcvbs">
if mcvbs.readystate="complete" and not isdrawn_ then
isdrawn_=true
drawinitialstate
end if
</script>

<script language="vbscript" event="
end if
</script>

<tr bgcolor="#3d55c4">
<td class="small">
<div class="small" align=center id="msngrheading" style="width:100%; color: #eff7ff; background-color:#3d55c4; padding:3px; padding-left:0px;"><b>msn messenger</b></div>

</td>
</tr>
<tr>
<td bgcolor="#eff7ff" class="small">
<div id="getmsgr" class="small" align=center style="display:none;color:#000000;"><br>download<br><a href="windows'>http://messenger.msn.com/">windows messenger</a>
<img id="mctrack" height="1" alt width="1">
</div>
<div id="msgrlogon" class="small" style="display:none">
<div id="statu" class="small" style="color:#000000"></div>
</div>
<!--online-->
<div id="online" class="small" style="display:none;color:#000000"></div> |||
<div id="noneol" class="small" style="display:none;color:#000000"></div>
<div id="muser" class="small" style="display:none;color:#000000"></div>
<br>
<!--offline-->
<div id="notonline" class="small" style="display:none;color:#000000">
<b><a href="javascript:void(null)" onclick="showhide(moff)" class="small"><img border="0" src="msn_icons/icon_messenger6.gif" width="16" height="16"> buddies offline</a></b>
</div>
<div id="moff" class="small" style="display:none; color:#000000"></div>
<span id="appload" class="small" style="display: none"></span>
</td>
<form name="msn">
<input type="hidden" value="on" name="offline">
</form>
</tr>
</table>
<br>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表