用于运行和停止滚动的Javascript按钮

时间:2016-09-28 13:46:36

标签: javascript scroll

我有一本书。我想要:

  • 一个开始慢速向下滚动的按钮,用户可以这样阅读。
  • 另一个停止滚动的按钮。

<div style="position:fixed">
  <button>play scroll</button>
  <button>stop scroll</button>
</div>
<br><br>
<p>
  <center>
    <h3>html history</h3>
  </center>
  In 1980, physicist Tim Berners-Lee, a contractor at CERN, proposed and prototyped ENQUIRE, a system for CERN researchers to use and share documents. In 1989, Berners-Lee wrote a memo proposing an Internet-based hypertext system.[3] Berners-Lee specified
  HTML and wrote the browser and server software in late 1990. That year, Berners-Lee and CERN data systems engineer Robert Cailliau collaborated on a joint request for funding, but the project was not formally adopted by CERN. In his personal notes[4]
  from 1990 he listed[5] "some of the many areas in which hypertext is used" and put an encyclopedia first. The first publicly available description of HTML was a document called "HTML Tags", first mentioned on the Internet by Tim Berners-Lee in late
  1991.[6][7] It describes 18 elements comprising the initial, relatively simple design of HTML. Except for the hyperlink tag, these were strongly influenced by SGMLguid, an in-house Standard Generalized Markup Language (SGML)-based documentation format
  at CERN. Eleven of these elements still exist in HTML 4.[8]HTML is a markup language that web browsers use to interpret and compose text, images, and other material into visual or audible web pages. Default characteristics for every item of HTML markup
  are defined in the browser, and these characteristics can be altered or enhanced by the web page designer's additional use of CSS. Many of the text elements are found in the 1988 ISO technical report TR 9537 Techniques for using SGML, which in turn
  covers the features of early text formatting languages such as that used by the RUNOFF command developed in the early 1960s for the CTSS (Compatible Time-Sharing System) operating system: these formatting commands were derived from the commands used
  by typesetters to manually format documents. However, the SGML concept of generalized markup is based on elements (nested annotated ranges with attributes) rather than merely print effects, with also the separation of structure and markup; HTML has
  been progressively moved in this direction with CSS. Berners-Lee considered HTML to be an application of SGML. It was formally defined as such by the Internet Engineering Task Force (IETF) with the mid-1993 publication of the first proposal for an HTML
  specification: "Hypertext Markup Language (HTML)" Internet-Draft by Berners-Lee and Dan Connolly, which included an SGML Document Type Definition to define the grammar.[9] The draft expired after six months, but was notable for its acknowledgment of
  the NCSA Mosaic browser's custom tag for embedding in-line images, reflecting the IETF's philosophy of basing standards on successful prototypes.[10] Similarly, Dave Raggett's competing Internet-Draft, "HTML+ (Hypertext Markup Format)", from late 1993,
  suggested standardizing already-implemented features like tables and fill-out forms.[11]
</p>

1 个答案:

答案 0 :(得分:0)

快速选秀:

<script>
  function play() {
    window.scrollBy(0,1);
    scrolldelay = setTimeout(play,10);
    }
  function stop() {
      clearTimeout(scrolldelay)
  }
</script>
<button onClick="play()">play scroll</button>
<button onClick="stop()">stop scroll</button>

您可以更改滚动速度更改scrollBy(滚动一个函数执行的像素数)和setTimeout(执行滚动的频率)。