一个使用htc来实现的连续滚动公告栏

博客提及代码编写已久未优化,包含调用的HTML代码、CSS代码以及ScrollViewDiv.htc,还给出了转载链接。主要围绕信息技术中的前端代码相关内容。

写了很久了,一直没有优化过。
调用的HTML代码:

None.gif<DIV CLASS="ScrollViewDiv" ID="ScrollViewDiv">内容在这里。。。。。。         </DIV>


CSS代码

ExpandedBlockStart.gifContractedBlock.gif.ScrollViewDiv {dot.gif}{
InBlock.gif    overflow 
: hidden;
InBlock.gif    height 
: 55px;
InBlock.gif    width 
: 100%;
InBlock.gif    behavior 
: url(ScrollViewDiv.htc);
ExpandedBlockEnd.gif
}

ScrollViewDiv.htc

None.gif<PUBLIC:ATTACH EVENT="onmouseover" ONEVENT="MouseOver()" />
None.gif
<PUBLIC:ATTACH EVENT="onmouseout" ONEVENT="MouseOut()" />
None.gif
<PUBLIC:ATTACH EVENT="oncontentready" ONEVENT="Init()" />
None.gif
<PUBLIC:PROPERTY name="content" id="_innerHtmlID" GET="getContent" PUT="setContent" />
None.gif
<PUBLIC:PROPERTY NAME="delayTime" ID="_delayTimeID" GET="getDelayTime" PUT="setDelayTime" />
None.gif
<PUBLIC:PROPERTY NAME="step" ID="_stepID" GET="getStep" PUT="setStep" />
ExpandedBlockStart.gifContractedBlock.gif
<SCRIPT LANGUAGE="javascript">dot.gif<!--
InBlock.gif
var _innerHTML    = "";
InBlock.gif
var _delayTime    = 300;
InBlock.gif
var _step        = 1;
InBlock.gif
var _div1;
InBlock.gif
var _div2;
InBlock.gif
var _continueScroll    = true;
InBlock.gif
function Init()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
if (_innerHTML == "")
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        _innerHTML    
= innerHTML;
ExpandedSubBlockEnd.gif    }

InBlock.gif    innerHTML    
= "";
InBlock.gif    _div1        
= document.createElement("DIV");
InBlock.gif    _div2        
= document.createElement("DIV");
InBlock.gif    appendChild(_div1);
InBlock.gif    appendChild(_div2);
InBlock.gif    
InBlock.gif    
if (_innerHTML == "")
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        _div1.innerHTML    
= "&nbsp;";
InBlock.gif        _div2.innerHTML    
= "&nbsp;";
ExpandedSubBlockEnd.gif    }

InBlock.gif    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        _div1.innerHTML    
= _innerHTML;
InBlock.gif        _div2.innerHTML    
= _innerHTML;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
InBlock.gif    RollUp();
ExpandedSubBlockEnd.gif}

InBlock.gif
function RollUp()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
if (_continueScroll)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
if (_div1.scrollHeight <= offsetHeight)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//高度小于实际高度时不滚动
InBlock.gif
            _div2.style.display    = "none";
InBlock.gif            scrollTop            
= 0;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
else
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _div2.style.display    
= "";
InBlock.gif
InBlock.gif            
if(_div2.offsetTop - scrollTop <= 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                scrollTop 
-= _div1.offsetHeight;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                scrollTop 
++;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif    window.setTimeout(RollUp , _delayTime);
ExpandedSubBlockEnd.gif}

InBlock.gif
function getContent()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
return _innerHTML;
ExpandedSubBlockEnd.gif}

InBlock.gif
function setContent(value)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    _innerHTML    
= value;
InBlock.gif    
InBlock.gif    
try
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
if (_innerHTML == "")
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _div1.innerHTML    
= "&nbsp;";
InBlock.gif            _div2.innerHTML    
= "&nbsp;";
ExpandedSubBlockEnd.gif        }

InBlock.gif        
else
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _div1.innerHTML    
= _innerHTML;
InBlock.gif            _div2.innerHTML    
= _innerHTML;
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif    
catch (e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif}

InBlock.gif
function getDelayTime()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
return _delayTime;
ExpandedSubBlockEnd.gif}

InBlock.gif
function setDelayTime(value)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
try
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        _delayTime 
= parseInt(value , 10);
InBlock.gif        
if (_delayTime <= 20)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _delayTime 
= 20;
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif    
catch (e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif}

InBlock.gif
function getStep()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
return _step;
ExpandedSubBlockEnd.gif}

InBlock.gif
function setStep(value)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    _step    
= value;
ExpandedSubBlockEnd.gif}

InBlock.gif
function MouseOver()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
try
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        _continueScroll    
= false;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
catch (e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif}

InBlock.gif
function MouseOut()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
try
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        _continueScroll    
= true;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
catch (e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif}

InBlock.gif
//--></SCRIPT>



 

转载于:https://www.cnblogs.com/bobowu/archive/2005/08/15/215464.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值