• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

用Javascript自动输出网页文本_js

javascript 搞代码 7年前 (2018-06-13) 162次浏览 已收录 0个评论

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

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

<SCRIPT LANGUAGE=”JavaScript”>
<!– Original: Tarjei Davidsen ([email protected]) –>
<!– 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;

http://www.gaodaima.com/?p=28654

  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″ >

OK,大功告成!

欢迎大家阅读《用Javascript自动输出网页文本_js,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:用Javascript自动输出网页文本_js

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址