Making active captions with JavaScript

Source: Internet
Author: User

Active subtitles is one of the most frequently used components in a Web page, which makes the entire Web page more dynamic and very angry. More and more active subtitles are being used to enhance the interactivity of Web pages. JavaScript programming can achieve a variety of active subtitle effects, the required code is very small, it can be a less download time for better results. The tag syntax is formatted as follows:

<marquee

Aligh=left/center/right/top/bottom

Bgcolor= #n

Font=n

Direction=left/right/up/down

Behavior=type

Height=n

Hspace=n

Scrollamount=n

Scrolldelay=n

Width=n

Vspace=n

Loop=n>

It can be seen that because of the various display of active subtitles, there are many optional parameters.

bgcolor: The background color used to set the active caption, typically the hexadecimal number.

Behavior: The way to set up scrolling is mainly in three ways: behavior= "Scroll" means scrolling from one end to the other, behavior= "slide" means to slide from one end to the other and not repeat; behavior= "alternate "means to scroll back and forth between the ends.

Hspace and Vspace: Sets the width of the left and right borders and the top and bottom borders of the scrolling marquee, respectively.

ScrollAmount: Used to set the distance for the active caption to scroll once.

Scrolldelay: Used to set the delay time between scrolling two times.

Loop: Sets the number of times to scroll, when loop=-1 indicates that it has been scrolling until the page is updated.

<marquee> The default is to scroll to the left indefinitely, the caption height is the text height, scrolling range: The width of the horizontal scroll is the width of the current position; the height of the vertical scroll is the height of the current position. Here are two scripting codes that implement special effects through JavaScript programming:

★ Horizontal Scrolling Marquee with links ★

Horizontal scrolling captions with links are generally used for advertising, very eye-catching:

<script language= "JavaScript" >

var marqueewidth=400

var marqueeheight=20

var speed=4

var marqueecontents= ' <strong><big> Welcome to <A > China Computer Education news website </a> Welcome to <a mailto:net@cc "> Give me a letter! </a></big></strong></font> '

document.write (' <marquee scrollamount= ' +speed+ ')

> ' +marqueecontents+ ' </marquee> ')

</script>

★ Vertical Scrolling Marquee with links ★

A vertical scrolling active caption is often used to publish news in a scrolling manner. In the script code, the parameters "behavior, derection, width, height, scrollamount, scrolldelay" respectively determine the rolling mode, rolling direction, width, height, one scrolling distance, delay time, etc., and the other parameters " The effect of onmouseover= ' this.stop () ' is that when the mouse pointer moves over the active marquee, the caption stops scrolling, and the argument "onmouseout= ' This.start ()" is exactly the opposite.

<script language=vbscript>document.write ("<marquee behavior=scroll direction=up width=130 Scrollamount=1 scrolldelay=60 onmouseover= ' this.stop () ' onmouseout= ' This.start () ' > ') </script>

<p><a >

</a><br>

<a >~=~>> Graduating class students leave school next week </a><br>

<a >~=~>>7 month 10th summer vacation </a><br>

<a >~=~>> Provincial Water Conservancy Conference held in our school </a><br><br>

<script Language=vbscript>document.write

("</marquee>") </script>

</p>

Embed the above code in the appropriate location on the Web page and change the content of the link to get a scrolling news bulletin bar.

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.