The technique of setting up random position of JS Div scroll bar _javascript skill

Source: Internet
Author: User
Style is used to qualify the div style and scroll bar, which is not much.
The key place is actually very simple, the last two lines of JavaScript, only the last line of work:
obj.scrolltop=obj.scrollheight* (Math.random ());
Obj.scrolltop: The position of the scroll bar from the top
Obj.scrollheight: Height of the flowing area
Math.random (): Get a random number
It's simple, someone may need it, just take it, haha
PS:IE6/IE7/FF2 Test Passed
IE7 a local test only when the scroll bar position is different, the refresh has not changed, but put on the site after the normal
The code is as follows:
<div id= "CC" > <li>01</li><li>02</li><li>03</li><li>04</li> <li>05</li><li>06</li><li>07</li><li>08</li> <li>09</ Li><li>10</li><li>11</li><li>12</li><li>13</li><li>14 </li><li>15</li><li>16</li> <li>17</li><li>18</li><li >19</li><li>20</li><li>21</li><li>22</li><li>23</li> <li>24</li> <li>25</li><li>26</li><li>27</li><li>28</ Li><li>29</li><li>30</li><li>31</li><li>32</li> <li>33 </li><li>34</li><li>35</li><li>36</li><li>37</li><li >38</li><li>39</li><li>40</li> <li>41</li><li>42</li>&Lt;li>43</li><li>44</li><li>45</li><li>46</li><li>47</li ><li>48</li> </div> <script> var obj = document.getElementById ("cc"); obj.scrolltop=obj.scrollheight* (Math.random ()); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.