Use JavaScript to create subtitles Http://www.sina.com.cn SCID Wang Weifu
Subtitle activity is one of the frequently used components in a webpage. It makes the whole webpage more dynamic and angry. Currently, more and more active subtitles are used on websites to enhance webpage interaction. Using JavaScript programming can achieve the effects of various subtitles. The required code is very small, and it can indeed get better results with less download time. The tag syntax is 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 there are many optional parameters due to the various display methods of active subtitles.
Bgcolor: used to set the background color of an active subtitle, which is generally a hexadecimal number.
Behavior: used to set the scroll mode, mainly in three ways: behavior = "scroll" means to scroll from one end to the other end; behavior = "slide" means to quickly slide from one end to the other end, and does not overlap; behavior = "alternate" means to scroll back and forth between the two ends.
The two parameters are used to set the width of the left and right sides and the upper and lower sides of the subtitles.
Scrollamount: used to set the distance between one scroll of an active subtitle.
Scrolldelay: used to set the delay between two scrolling times.
Loop: used to set the number of scrolling times. When loop =-1, it means to scroll down until the page is updated.
<Marquee> by default, the label is scaled infinitely to the left, the subtitle height is the text height, and the scroll range: the horizontal scroll width is the width of the current position; the vertical scroll height is the height of the current position. The following are two script codes that implement Subtitles with special effects through JavaScript programming:
★Horizontal Subtitles with links★
Horizontal scrolling Subtitles with links are generally used for Ad Promotion and are very eye-catching:
<Script language = "JavaScript"> "〉
VaR marqueewidth = 400
VaR marqueeheight = 20
VaR speed = 4
VaR marqueecontents = '<strong> <big> welcome to <a href = "www.cce.com.cn"> China Computer Education news website </a>. Welcome to <a href = "mailto: net@cce.com.cn "> send me a letter! </A> </big> </strong> </font> 〉'
Document. Write ('<marquee scrollamount =' + speed + 'style = "width:' + marqueewidth + '"
> '+ Marqueecontents +' </marquee> 〉')
</SCRIPT> 〉
★Vertical scroll Subtitles with links★
Vertical scrolling subtitles are often used to publish news in scrolling mode. In the script code, the parameters behavior, Derection, width, height, scrollamount, and scrolldelay determine the scrolling method, scrolling direction, width, height, one-time scrolling distance, and delay time of the active subtitles., in addition, the parameter "onmouseover = 'this. stop () '"means that when the mouse pointer moves to the active subtitle, the subtitle stops scrolling. The parameter" onmouseout = 'this. start () '"is the opposite.
<Script language = VBScript> document. write ("<marquee behavior = scroll ction = up width = 130 Height = 80 scrollamount = 1 scrolldelay = 60 onmouseover = 'this. stop () 'onmouseout = 'this. start () '> ") </SCRIPT> 〉
<P> <a href = "www.sohu.com"> "〉
</A> <br> 〉
<A href = "xwgg/bys.htm"> "〉~ = ~ > Graduating students leave school next week </a> <br> 〉
<A href = "xwgg/fj.htm"> "〉~ = ~ > Summer vacation in July 10 </a> <br> 〉
<A href = "xwgg/slnh"> "〉~ = ~ > The provincial water conservancy annual meeting is held in our school </a> <br> 〉
<Script language = VBScript> document. Write
("</Marquee>") </SCRIPT> 〉
</P> 〉
Embed the above code into a proper position on the webpage, and change the link content to get a rolling news bulletin board. (Responsible editor Ray)