Tips for setting random positions of js DIV scroll bars

Source: Internet
Author: User

The style is used to limit the DIV style and add a scroll bar.
The key is actually very simple. The last two lines of Javascript work only on the last line:
Obj. scrollTop = obj. scrollHeight * (Math. random ());
Obj. scrollTop: the position of the scroll bar from the top
Obj. scrollHeight: the height of the flow area
Math. random (): obtain a random number.
It's very simple. Someone may need it. Take it for use. Haha
PS: IE6/IE7/FF2 passed the test
During the local test of IE7, the position of the scroll bar is different only when it is opened each time, but the refresh is not changed, but it will be normal after it is placed on the website.
The Code is as follows:
<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> <li> 43 </li> <li> 44 </li> <li> 45 </li> <li> 46 </li> <li> 47 </li> <li> 48 </li>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Related Article

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.