JavaScript instance link buttons are constantly changing

Source: Internet
Author: User

Buttons are common in Web pages. However, you may not have seen the link using buttons. In this way, you can use buttons to create links, and the links in the buttons are constantly displayed. The results are very nice and can save page space. You have to give it a try!

Click here to view the effect

1. Add the following program code to the
<Script language = "JavaScript">
<! -- Begin
// Please help yourself to this code.
Var startTime = null;
Var timerID = null;
Var initial = new Date ();
Var pos = 0;
Var menuItem = null;

Function initArray (){
This. length = initArray. arguments. length
For (var I = 0; I <this. length; I ++ ){
This [I + 1] = initArray. arguments [I]
}
}

Function parsemenuItem (data, num ){
For (var I = 0; I <data. length; I ++ ){
If (data. substring (I, I + 1) = "|") break;
}
If (num = 0) return (data. substring (0, I ));
Else return (data. substring (I + 1, data. length ));
}

Function startTimer (){
Initial = new Date ();
StartTime = initial. getTime ();
StopTimer ();
MenuItem = new initArray ("SCID Windows world | http://www.ccidnet.com/school/system ",
"SCID web surfing compass | http://www.ccidnet.com/school/net ",
"SCID Software Download Park | http://www.ccidnet.com/school/soft ",
"SCID Network Office Automation | http://www.ccidnet.com/school/office ",
"SCID software e school | http://www.ccidnet.com/school/software ",
"SCID network multimedia house | http://www.ccidnet.com/school/multimedia ",
"SCID network training and examination | http://www.ccidnet.com/school/exam ",
"SCID Network Computer dictionary | http://www.ccidnet.com/school/dict"
);
ShowTimer ();
}

Function stopTimer (){
TimerID = null;
MenuItem = null;
// ClearTimeout (timerID );
}

Function showTimer (){
Pos = (pos = menuItem. length )? 1: pos + 1;
Document. forms [0]. elements [0].
Value = parsemenuItem (menuItem [pos], 0 );

TimerID = window. setTimeout ('showtimer () ', 4000 );
}

Function goToUrl (){
// Parent. welcome. location = parsemenuItem (menuItem [pos], 1 );
This. location = parsemenuItem (menuItem [pos], 1 );
Return (false );
}
// End -->
</SCRIPT>


Note: you can modify the link and description above. In the above section ('showtimer () ', 4000), 4000 is used to set the speed of changes between links. The smaller the number, the faster the speed.


2. Add the following code to the <body> area.


<FORM>
<Input type = "button" VALUE = "zhouqing" NAME = "goTo"
OnClick = "window. goToUrl ()">
</FORM>

3. Change the content in <body> to the following code.

<Body bgcolor = "# ffffff" onLoad = "window. startTimer ()">

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.