Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->网站设计 ->JavaScript ->正文

用Javascript自动输出网页文本

来源:Linuxdby.com 作者:Webmaster 时间:2007-04-13 点击: [收藏] [投稿]

  在网页中经常有人使用Swish来做文本输出的打字效果,其实JavaScript也能做出那样的效果,按如下方法在HTML文件中加入JavaScript代码便可。

第一步:把如下代码加入<head>区域中

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Tarjei Davidsen (the@rescueteam.com) -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
  var max=0;

  function textlist() {

  max=textlist.arguments.length;

  for (i=0; i<max; i++)

  this[i]=textlist.arguments[i];}

  tl = new textlist( "在此输入要输出的文字");

  var x = 0; pos = 0;

  var l = tl[0].length;

  function textticker() {

  document.tickform.tickfield.value = tl[x].substring(0, pos) + "_";

  if(pos++ == l) {

  pos = 0;

  setTimeout("textticker()", 2000);

  if(++x == max) x = 0;

  l = tl[x].length;

  } else

  setTimeout("textticker()", 50);}

  // End --></script>

第二步:把如下代码加入<body>区域中

<form name=tickform>

<textarea name=tickfield rows=3 cols=38 style="background-color: rgb(0,0,0); color: rgb(255,255,255); cursor: default; font-family: Arial; font-size: 12px" wrap=virtual>The news will appear here when the page has finished loading.</textarea></form>

第三步:把<body>改为<body bgcolor="#fef4d9" OnLoad="textticker()">

OK,大功告成!





 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇: IE NC通用的藏鼠标右键一法   下一篇: 网页状态栏特效全攻略

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号