The special effects code of continuous rolling of Web page text

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax code content continuous function html http javascript

<div id= "Marquees" > <!--these are the contents of the caption, you can define-->
<a href=http://www.jzread.com/web/js/2010-01-08/ 376.html> scrolling text link 1</a>
<br> <a href=http://www.jzread.com/web/js/2010-01-08/376.html> Scrolling text links 2</a>
<br> <a href=http://www.jzread.com/web/js/2010-01-08/376.html> scrolling text links 3</a
<br> <a href=http://www.jzread.com/web/js/2010-01-08/376.html> scrolling text link 4</a>
<br > <!--subtitles end of
</div>
<!--The following are JavaScript code
<script language= "JavaScript" >
<!--
marqueesheight=200//content area height
Stopscroll=false//This variable controls whether to stop scrolling
with (marquees) {
Nowrap=true ; The content area of this table does not wrap
style.width=0;//So we can set its width to 0 because it will be propped up
Style.height=marqueesheight
style.overflowy= Hidden "; Scroll bars are not visible
Onmouseover=new function ("stopscroll=true");//mouse over, stop scrolling
onmouseout=new function ("Stopscroll=false "); Mouse left, start scrolling
}
//At this point, the height of the content area is unreadable. The following outputs an invisible layer "templayer", which is later copied to theInside:
document.write (' <div id= "Templayer" style= "Position:absolute;z-index:1;visibility:hidden" ></div > ');
Function init () {//Initialize scrolling content
//multiple copies of the original content to "Templayer" until the height of "templayer" is greater than the content area height:
While Templayer.offsetheight <marqueesheight) {
templayer.innerhtml+=marquees.innerhtml
}///copy "Templayer" content "twice times" back to the original content area:
marquees.innerhtml=templayer.innerhtml+templayer.innerhtml;
//sets a continuous timeout, invoking the Scrollup () function to drive the scroll bar:
SetInterval ("Scrollup ()",),
}
Document.body.onload=init;
Pretop=0//This variable is used to determine if the scroll bar has reached its end
function Scrollup () {//scroll bar's driver
if (stopscroll==true) return; Stopscroll "True, stop scrolling
pretop=marquees.scrolltop//record scroll bar position before scrolling
marquees.scrolltop+=1//Scroll down one pixel
// If the scroll bar does not move, scroll up to the same position as the current screen
//not only that, but also scroll down one pixel (+1):
if (pretop==marquees.scrolltop) {
marquees.scrolltop=templayer.offsetheight-marqueesheight+1;
}

</script>
;

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.