Home > Web Front-end > JS Tutorial > How to use JavaScript script to achieve scrolling effect

How to use JavaScript script to achieve scrolling effect

PHPz
Release: 2018-10-12 17:27:25
Original
1261 people have browsed it

This article mainly introduces the method of using JavaScript script to achieve scrolling effect, that is, a bulletin board display-like effect. Friends who need it can refer to it

Many friends who make web pages often make bulletin boards and information Window, I often worry about realizing the scrolling display of the whole page and images. Don't worry, here is a simple method to realize the scrolling display. We did not use Java's .class program to implement it, nor was it a dynamic DHTML language. We just made full use of some functions of the JavaScript script language and wrote some short JavaScript script language to achieve this function.

The original code is as follows:

<html>
  <head>
  <script language="Javascript">
  <!--//防止错误显示
  locate=0;
  function my_scroller()
  {
   if (locate !=400 )
  {
   locate++;//值增加
   scroll(0,locate);
   clearTimeout(timer);
   var timer = setTimeout("my_scroller()",2);//控制滚动时间
   timer;
  }
  }
   -->
  </script>
  </head>
  <body OnLoad="my_scroller()">
  作者简介:<br><br>
  崔同杰男<br><br>武警工程学院计算机中心<br><br>
  张卫华男<br><br>武警工程学院研究生队<br><br><br><br><br>
  <br><br><br><br><br><br>
  联系地址:<br><br>
  陕西西安武警工程学院计算机中心<br><br>崔同杰<br><br></body>
  </html>
Copy after login

You can control the length of the displayed page by changing the value of Locate (the original code is Locate!= 400); You can modify "2" in "SetTimeout("Scroller()",2);" to change the scrolling speed. You can try making some adjustments separately. After the program is written and saved, it must be debugged on the PII PWS4.0 IE5 platform.

For more related tutorials, please visit JavaScript Tutorial

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template