2016-09-28 22 views
0

我有一本書。我想要:用於運行和停止滾動的Javascript按鈕

  • 一個按鈕開始慢速向下滾動,這樣用戶可以閱讀。
  • 另一個停止滾動的按鈕。

<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

你試過的JS代碼是? – DaniP

+0

我嘗試了幾個代碼,但不符合我的項目@DaniP –

+0

使用Jquery或只是普通的JS的機會? – DaniP

回答

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的速度(頻率執行滾動)。

+0

感謝您的回答,請等待測試 –

+0

他不工作insaid [onsen ui](https://onsen.io/v2/docs/指導/ js /)框架 –

+0

你有沒有把'''''?你可以將play和stop函數放入控制檯並運行'play()','stop()'來檢查它是如何工作的 – jonzee