js使用MSCOMM控件发送十六进制数据怎么处理
展开全部
我之前写过一个,很简单,也就下面几个函数:
function topOfList()
{
var btn = document.getElementById('topOfListBtn');
if(btn.state == 'spaned')
{
var forms = document.getElementsByTagName('form');
var timeSpan = 50;
for(var i = 0;i<forms.length;i++)
{
var form = forms[i];
if(form.id.indexOf('Top') > -1)
{
ShinkSlowly(form,timeSpan);
timeSpan += 50;
}
}
btn.state = 'unspaned';
changeBtnImg('topOfListImg','img/unspaned.jpg');
tellConsoleSpanSate();
}
else
{
var forms = document.getElementsByTagName('form');
var timeSpan = 50;
for(var i = 0;i<forms.length;i++)
{
var form = forms[i];
if(form.id.indexOf('Top') > -1)
{
SpanSlowly(form,timeSpan);
timeSpan += 50;
}
}
btn.state = 'spaned';
changeBtnImg('topOfListImg','img/spaned.jpg');
tellConsoleSpanSate();
}
}
function bottomOfList()
{
var btn = document.getElementById('bottomOfListBtn');
if(btn.state == 'spaned')
{
var forms = document.getElementsByTagName('form');
var timeSpan = 50;
for(var i = 0;i<forms.length;i++)
{
var form = forms[i];
if(form.id.indexOf('Bottom') > -1)
{
ShinkSlowly(form,timeSpan);
timeSpan += 50;
}
}
btn.state = 'unspaned';
changeBtnImg('bottomOfListImg','img/unspaned.jpg');
tellConsoleSpanSate();
}
else
{
var forms = document.getElementsByTagName('form');
var timeSpan = 50;
for(var i = 0;i<forms.length;i++)
{
var form = forms[i];
if(form.id.indexOf('Bottom') > -1)
{
SpanSlowly(form,timeSpan);
timeSpan += 50;
}
}
btn.state = 'spaned';
changeBtnImg('bottomOfListImg','img/spaned.jpg');
tellConsoleSpanSate();
}
}
function ShinkSlowly(form,timeSpan)//控制按钮收缩的函数
{
setTimeout(function()
{
form.style.display = 'none';
}
,timeSpan);
}
function SpanSlowly(form,timeSpan)//控制按钮展开的函数
{
setTimeout(function()
{
form.style.display = '';//alert(form.id);
}
,timeSpan);
}
function changeBtnImg(imgId, imgSrc)
{
document.getElementById(imgId).src=imgSrc;//'img/unspaned.jpg';'img/spaned.jpg';
}
其中,imgSrc要换成你硬盘里存在的图片路径。然后在你的+号图片的单击事件响应使用topOfList()函数即可,我测试过,可用。ShinkSlowly()函数内部可以控制张开和收缩的速度。
function topOfList()
{
var btn = document.getElementById('topOfListBtn');
if(btn.state == 'spaned')
{
var forms = document.getElementsByTagName('form');
var timeSpan = 50;
for(var i = 0;i<forms.length;i++)
{
var form = forms[i];
if(form.id.indexOf('Top') > -1)
{
ShinkSlowly(form,timeSpan);
timeSpan += 50;
}
}
btn.state = 'unspaned';
changeBtnImg('topOfListImg','img/unspaned.jpg');
tellConsoleSpanSate();
}
else
{
var forms = document.getElementsByTagName('form');
var timeSpan = 50;
for(var i = 0;i<forms.length;i++)
{
var form = forms[i];
if(form.id.indexOf('Top') > -1)
{
SpanSlowly(form,timeSpan);
timeSpan += 50;
}
}
btn.state = 'spaned';
changeBtnImg('topOfListImg','img/spaned.jpg');
tellConsoleSpanSate();
}
}
function bottomOfList()
{
var btn = document.getElementById('bottomOfListBtn');
if(btn.state == 'spaned')
{
var forms = document.getElementsByTagName('form');
var timeSpan = 50;
for(var i = 0;i<forms.length;i++)
{
var form = forms[i];
if(form.id.indexOf('Bottom') > -1)
{
ShinkSlowly(form,timeSpan);
timeSpan += 50;
}
}
btn.state = 'unspaned';
changeBtnImg('bottomOfListImg','img/unspaned.jpg');
tellConsoleSpanSate();
}
else
{
var forms = document.getElementsByTagName('form');
var timeSpan = 50;
for(var i = 0;i<forms.length;i++)
{
var form = forms[i];
if(form.id.indexOf('Bottom') > -1)
{
SpanSlowly(form,timeSpan);
timeSpan += 50;
}
}
btn.state = 'spaned';
changeBtnImg('bottomOfListImg','img/spaned.jpg');
tellConsoleSpanSate();
}
}
function ShinkSlowly(form,timeSpan)//控制按钮收缩的函数
{
setTimeout(function()
{
form.style.display = 'none';
}
,timeSpan);
}
function SpanSlowly(form,timeSpan)//控制按钮展开的函数
{
setTimeout(function()
{
form.style.display = '';//alert(form.id);
}
,timeSpan);
}
function changeBtnImg(imgId, imgSrc)
{
document.getElementById(imgId).src=imgSrc;//'img/unspaned.jpg';'img/spaned.jpg';
}
其中,imgSrc要换成你硬盘里存在的图片路径。然后在你的+号图片的单击事件响应使用topOfList()函数即可,我测试过,可用。ShinkSlowly()函数内部可以控制张开和收缩的速度。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询