2013-07-11
展开全部
第一步:请修改<BODY>:
<BODY onload=init()>
第二步:将以下代码加入HEML的<BODY></BODY>之间
<script language=javascript>
var layers =document.layers,style=document.all,both=layers||style,idme=908601;
if(layers){layerRef='document.layers';styleRef ='';}if(style){layerRef='document.all';styleRef = <br/>'.style';}
function writeOnText(obj,str){
if(layers)with(document[obj]){ document.open();document.write(str);document.close();}
if(style)eval(obj+'.innerHTML=str'); }
var dispStr=new Array("打字效果代码");//这里面的就是内容文字
var overMe=0;
function txtTyper(str,idx,idObj,spObj,clr1,clr2,delay,plysnd){
var tmp0=tmp1= '',skip=100;
if (both && idx<=str.length) {
if (str.charAt(idx)=='<'){ while(str.charAt(idx)!='>') idx++;idx++;}
if (str.charAt(idx)=='&'&&str.charAt(idx+1)!=' '){ while (str.charAt(idx)!= ';')idx++;idx++;}
tmp0 = str.slice(0,idx);
tmp1 = str.charAt(idx++);
if (overMe==0 && plysnd==1){
if (navigator.plugins[0]){
if(navigator.plugins["LiveAudio"][0].type=="audio/basic" && navigator.javaEnabled()){document.embeds<br/>[0].stop();<br/>setTimeout("document.embeds[0].play(false)",100);}
} else if (document.all){
ding.Stop();
setTimeout("ding.Run()",100);}
overMe=1;}else overMe=0;
writeOnText(idObj, "<span class="+spObj+"><font color='"+clr1+"'>"+tmp0+"</font><font color='"+clr2
+"'>"+tmp1+"</font></span>");
setTimeout("txtTyper('"+str+"', "+idx+", '"+idObj+"', '"+spObj+"', '"+clr1+"', '"+clr2+"', "+delay+" ,"+plysnd+")",delay);}}
function init(){txtTyper(dispStr[0], 0, 'ttl0', 'ttl1', '#339933', '#99FF33', 300, 0);}
</script>
<DIV class=ttl1 id=ttl0></DIV>
<BODY onload=init()>
第二步:将以下代码加入HEML的<BODY></BODY>之间
<script language=javascript>
var layers =document.layers,style=document.all,both=layers||style,idme=908601;
if(layers){layerRef='document.layers';styleRef ='';}if(style){layerRef='document.all';styleRef = <br/>'.style';}
function writeOnText(obj,str){
if(layers)with(document[obj]){ document.open();document.write(str);document.close();}
if(style)eval(obj+'.innerHTML=str'); }
var dispStr=new Array("打字效果代码");//这里面的就是内容文字
var overMe=0;
function txtTyper(str,idx,idObj,spObj,clr1,clr2,delay,plysnd){
var tmp0=tmp1= '',skip=100;
if (both && idx<=str.length) {
if (str.charAt(idx)=='<'){ while(str.charAt(idx)!='>') idx++;idx++;}
if (str.charAt(idx)=='&'&&str.charAt(idx+1)!=' '){ while (str.charAt(idx)!= ';')idx++;idx++;}
tmp0 = str.slice(0,idx);
tmp1 = str.charAt(idx++);
if (overMe==0 && plysnd==1){
if (navigator.plugins[0]){
if(navigator.plugins["LiveAudio"][0].type=="audio/basic" && navigator.javaEnabled()){document.embeds<br/>[0].stop();<br/>setTimeout("document.embeds[0].play(false)",100);}
} else if (document.all){
ding.Stop();
setTimeout("ding.Run()",100);}
overMe=1;}else overMe=0;
writeOnText(idObj, "<span class="+spObj+"><font color='"+clr1+"'>"+tmp0+"</font><font color='"+clr2
+"'>"+tmp1+"</font></span>");
setTimeout("txtTyper('"+str+"', "+idx+", '"+idObj+"', '"+spObj+"', '"+clr1+"', '"+clr2+"', "+delay+" ,"+plysnd+")",delay);}}
function init(){txtTyper(dispStr[0], 0, 'ttl0', 'ttl1', '#339933', '#99FF33', 300, 0);}
</script>
<DIV class=ttl1 id=ttl0></DIV>
展开全部
这是存放内容的DIV
ID为test
原理是通过改变一个div的innerHTML来实现,用setInterval设定每隔一段时间就改变div的innerHTML看起来好象逐字打印一样
ID为test
原理是通过改变一个div的innerHTML来实现,用setInterval设定每隔一段时间就改变div的innerHTML看起来好象逐字打印一样
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-11
展开全部
<script language="javascript" type="text/javascript">
function _print(i,str){
this[i] = {
o: document.getElementById(i),
str:str,
i: 0
}
this[i].setint = setInterval(
(
function(obj)
{
return function(){
obj.o.innerHTML += obj.str.charAt(obj.i);
obj.i+=1;
if(obj.i == obj.str.length)
{
clearInterval(obj.setint);
obj = null;
}
}
}
)(this[i]),100);
}
</script>
<div id="test">这是存放内容的DIV ID为test</div>
<input type="button" value="new _print('test','按钮1打印的字符');" onclick="new _print('test','按钮1打印的字符')" />
<input type="button" value="清空内容" onclick="document.getElementById('test').innerHTML = ''" />
原理是通过改变一个div的innerHTML来实现,用setInterval设定每隔一段时间就改变div的innerHTML看起来好象逐字打印一样
function _print(i,str){
this[i] = {
o: document.getElementById(i),
str:str,
i: 0
}
this[i].setint = setInterval(
(
function(obj)
{
return function(){
obj.o.innerHTML += obj.str.charAt(obj.i);
obj.i+=1;
if(obj.i == obj.str.length)
{
clearInterval(obj.setint);
obj = null;
}
}
}
)(this[i]),100);
}
</script>
<div id="test">这是存放内容的DIV ID为test</div>
<input type="button" value="new _print('test','按钮1打印的字符');" onclick="new _print('test','按钮1打印的字符')" />
<input type="button" value="清空内容" onclick="document.getElementById('test').innerHTML = ''" />
原理是通过改变一个div的innerHTML来实现,用setInterval设定每隔一段时间就改变div的innerHTML看起来好象逐字打印一样
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-11
展开全部
直接用html的marquee就行了啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询