<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>向左滚动的文字特效JS代码</title>
</head>
<body>
<div id="demo" style="overflow:hidden;height:20px; line-height:20px;width:300px; border:0px; white-space:nowrap;">
<div id="demo1">新野大葱网是新野大葱种植基地专业的营销网站!新野大葱种植基地欢迎您来选购!</div>
<div id="demo2"></div>
</div>
<script style="text/javascript">
var speed=40;//数值越大,速度越慢
var demo2=document.getElementById("demo2");
var demo1=document.getElementById("demo1");
var demo=document.getElementById("demo");
function MarqueeLeft(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(MarqueeLeft,speed);
demo.onmouseover=function() {clearInterval(MyMar);}
demo.onmouseout=function() {MyMar=setInterval(MarqueeLeft,speed);}
</script>
</body>
</html>
此段代码在gb2312编码下面可以连续滚动,把编码转换成utf-8之后,不能连续滚动,请哪位高手看看这是什么原因?急?有哪位高手有好的向左滚动的代码可以帖出来,大家一块学习学习!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>向左滚动的文字特效JS代码</title>
</head>
<body>
<div id="demo" style="overflow:hidden;height:20px; line-height:20px;width:300px; border:0px; white-space:nowrap;">
<div id="demo1">新野大葱网是新野大葱种植基地专业的营销网站!新野大葱种植基地欢迎您来选购!</div>
<div id="demo2"></div>
</div>
<script style="text/javascript">
var speed=40;//数值越大,速度越慢
var demo2=document.getElementById("demo2");
var demo1=document.getElementById("demo1");
var demo=document.getElementById("demo");
function MarqueeLeft(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(MarqueeLeft,speed);
demo.onmouseover=function() {clearInterval(MyMar);}
demo.onmouseout=function() {MyMar=setInterval(MarqueeLeft,speed);}
</script>
</body>
</html>
此段代码在gb2312编码下面可以连续滚动,把编码转换成utf-8之后,不能连续滚动,请哪位高手看看这是什么原因?急?有哪位高手有好的向左滚动的代码可以帖出来,大家一块学习学习!
提醒:编码格式不能强制转换,特别是当存在中文时强制转换中文将成乱码。