Continuous subtitle scrolling

Source: Internet
Author: User

<HTML> <Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> Devil Li Jiang </title>
</Head>
<Body>

<Table>
<Tr>
<TD> <Div id = "marquees"> <! -- These are subtitle content, which you can define at will --> <a href = "#"> link 1 </a>
<Br> <a href = "#"> link 2 </a>
<Br> <a href = "#"> link 3 </a>
<Br> <a href = "#"> Link 4 </a>
<Br> <! -- Subtitle content ends -->
<Br> <a href = "#"> Link 4 </a>
<Br> <a href = "#"> Link 4 </a>
<Br> <a href = "#"> Link 4 </a>
<Br> <a href = "#"> Link 4 </a>
<Br> <a href = "#"> Link 4 </a>
<Br> <a href = "#"> Link 4 </a>
</Div> </TD>
</Tr>
</Table>

<! -- The following is a Java-scriptCode-->
<SCRIPT>
<! --
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 automatically wrap.
Style. width = 0; // we can set its width to 0, because it will be extended.
Style. Height = marqueesheight;
Style. overflowy = "hidden"; // the scroll bar is invisible.
Onmouseover = new function ("stopscroll = true"); // move the mouse over to stop scrolling.
Onmouseout = new function ("stopscroll = false"); // move the mouse away to start rolling.
}

// At this time, the height of the content area cannot be read. The following output is an invisible layer "templayer", and the content will be copied to it later:
Document. Write ('<Div id = "templayer" style = "position: absolute; Z-index: 1; visibility: hidden"> </div> ');

Pretop = 0; // This variable is used to determine whether the scroll bar has reached its end.

Function Init (){
// Initialize the scrolling content
// Copy the original content multiple times to "templayer" until the height of "templayer" is greater than that of the content area:
While (templayer. offsetheight <marqueesheight ){
Templayer. innerhtml + = marquees. innerhtml;
} // Copy twice the content of "templayer" to the original content area:
Marquees. innerhtml = templayer. innerhtml + templayer. innerhtml;
// Set the continuous timeout. Call the "scrollup ()" function to drive the scroll bar:
Setinterval ("scrollup ()", 40 );
}

Function scrollup () {// The driver function of the scroll bar
If (stopscroll = true) return; // If the variable "stopscroll" is true, stop scrolling.
Pretop = marquees. scrolltop; // record the position of the scroll bar before scrolling
Marquees. scrolltop + = 1; // the scroll bar moves down a pixel.
// If the scroll bar does not move, it will scroll up to the same position as the current screen.
// Of course not only that, but also to scroll down a pixel (+ 1 ):
If (pretop = marquees. scrolltop ){
Marquees. scrolltop = templayer. offsetheight-marqueesheight + 1;
}
}

Init ();
-->
</SCRIPT>

</Body>

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.