Write a program with JavaScript to implement text scrolling

Source: Internet
Author: User
Javascript| Program

On some pages, we often see some scrolling text, cool, how to do it?

Below we take Xu Zhimo's one "again Kangqiao" as an example, uses the JavaScript to write a program, realizes the text to scroll.

1. Run the Dreamweaver application and click the "Show Code View and Design View" button in the toolbar.

In the Open Code window, insert the following section of code into the < head> area.

< SCRIPT language= "JavaScript" >

<!--Begin

function Selectscroller (n) {

Optlist = Document.scrollform.scroller;

Optlist[optlist.length] = new Option (Optlist[0].text, "", false, false);

OPTLIST[0] = null;

Optlist.selectedindex =-1;

n = (n + 1)% Optlist.length;

settimeout ("Selectscroller" ("+n+") ", 2000);

}</p>

</script>

This code is designed to control the speed at which text is played.

2. Add the following code to the area

< form name= "Scrollform" >

< select Name= "Scroller" size=8>

< option> softly I'm gone,

< option> as softly as I come;

< option> I waved softly,

< option> the clouds in the western paradise.

< option>

< The golden willow of the river Option>,

......

< option> quietly I'm gone,

< option> as I come quietly;

< option> I waved my sleeve,

< option> not take away a cloud.

This program is designed to control the size of the text box and to display the scrolling text content.

3. Change the < body> to

< BODY >

After embedding the above code, press the F12 key to view the effect.



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.