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>≪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]