//--------------------------------------------左右滾動效果----------------------------------------------
/*
AppendToObj: 顯示位置(目標對象)
ShowHeight: 顯示高度
ShowWidth: 顯示寬度
ShowText: 顯示信息
ScrollDirection: 滾動方向(值:left、right)
Steper: 每次移動的間距(單位:px;數值越小,滾動越流暢,建議設置為1px)
Interval: 每次執(zhí)行運動的時間間隔(單位:毫秒;數值越小,運動越快)
*/
function ScrollText(AppendToObj,ShowHeight,ShowWidth,ShowText,ScrollDirection,Steper,Interval){
var TextWidth,PosInit,PosSteper;
with(AppendToObj){
html('');
css('overflow','hidden');
css('height',ShowHeight+'px');
css('line-height',ShowHeight+'px');
css('width',ShowWidth);
}
if (ScrollDirection=='left'){
PosInit = ShowWidth;
PosSteper = Steper;
}
else{
PosSteper = 0 - Steper;
}
if(Steper<1 || Steper>ShowWidth){Steper = 1}//每次移動間距超出限制(單位:px)
if(Interval<1){Interval = 10}//每次移動的時間間隔(單位:毫秒)
var Container = $('<div></div>');
var ContainerID = 'ContainerTemp';
var i = 0;
while($('#'+ContainerID).length>0){
ContainerID = ContainerID + '_' + i;
i++;
}
with(Container){
attr('id',ContainerID);
css('float','left');
css('cursor','default');
appendTo(AppendToObj);
html(ShowText);
TextWidth = width();
if(isNaN(PosInit)){PosInit = 0 - TextWidth;}
css('margin-left',PosInit);
mouseover(function(){
clearInterval(ScrollTime);
});
mouseout(function(){
ScrollTime = setInterval("ScrollAutoPlay('"+ContainerID+"','"+ScrollDirection+"',"+ShowWidth+','+TextWidth+","+PosSteper+")",Interval);
});
}
ScrollTime = setInterval("ScrollAutoPlay('"+ContainerID+"','"+ScrollDirection+"',"+ShowWidth+','+TextWidth+","+PosSteper+")",Interval);
}
</script>
<script type="text/javascript">
$(document).ready(function(e) {
ScrollText($('#scrollText'),23,400,'歡迎光臨武林網!','left',1,20);//滾動字幕
});
</script>
<body>
<div id="scrollText"></div>
<script type="text/javascript">
if(document.getElementById('GoogleAD')!=null){
document.getElementById('GoogleAD').innerHTML = '<div class="SearchEngine_AD1">' + document.getElementById('GoogleADCode').innerHTML + '</div>';
}
</script>
</body>
</html>
|
新聞熱點
疑難解答