Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use JavaScript to make link buttons change constantly

Shulou Source: shulou.com Published: 2022-06-02 08:19:30 10月02日 Update

This article focuses on "how to use JavaScript to make link buttons constantly change", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to use JavaScript to make link buttons constantly change".

First, add the following program code to

< head >

< /head >

In the area.

< 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("赛迪网Windows世界|http://www.ccidnet.com/school/system/", "赛迪网冲浪指南针|http://www.ccidnet.com/school/net/", "赛迪网软件下载园|http://www.ccidnet.com/school/soft/", "赛迪网办公自动化|http://www.ccidnet.com/school/office/", "赛迪网软件e学堂|http://www.ccidnet.com/school/software/", "赛迪网多媒体之家|http://www.ccidnet.com/school/multimedia/", "赛迪网培训与考试|http://www.ccidnet.com/school/exam/", "赛迪网电脑大词典|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: the links and instructions above can be modified by yourself. 4000 in the above ('showTimer ()', 4000) is used to set the speed of change between links. The smaller the number, the faster the speed.

Add the following code to the

< body >

In the area.

< FORM >

< INPUT TYPE="button" VALUE=" zhouqing " NAME="goTo" onClick="window.goToUrl()" >

< /FORM >

Third, finally put

< body >

Change the contents of the following code.

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

At this point, I believe you have a deeper understanding of "how to use JavaScript to make link buttons constantly change". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Sadie Sadie links changes constantly buttons code content face region software learning practical deeper world home between interest multimedia school Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Microsoft MariaDB Shulou Technology Shulou Tech Info