JS實(shí)現(xiàn)自動(dòng)變化的導(dǎo)航菜單效果代碼
本文實(shí)例講述了JS實(shí)現(xiàn)自動(dòng)變化的導(dǎo)航菜單效果代碼。分享給大家供大家參考。具體如下:
自動(dòng)變化的JS導(dǎo)航菜單,按照時(shí)間自動(dòng)切換,有需要的參考一下。
運(yùn)行效果截圖如下:

在線演示地址如下:
http://demo.jb51.net/js/2015/js-auto-cha-nav-menu-style-codes/
具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>導(dǎo)航菜單</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
site = "http://www.qq.com"; // Do not include the final "/"
function combineMenus(frm, menu1, menu2) {
with (frm) {
str = menu1.options[menu1.selectedIndex].value;
str += menu2.options[menu2.selectedIndex].value;
url = site + "/" + str + ".htm";
window.location.href = url;
}
}
// End -->
</script>
<form name=menufrm>
<select name=menu1>
<option value="">時(shí)間類</option>
<option value="time">time</option>
</select>
<select name=menu2>
<option value="">哪個(gè)</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type=button value="Select" onClick="combineMenus(this.form, this.form.menu1, this.form.menu2)">
</form>
<SCRIPT LANGUAGE="JavaScript">
function makeArray(q){
for(i=1 ; i < q ; i++){this[i]=0}}
w=1;
howmanysites=4; // How many sites are listed below?
Sites = new makeArray(howmanysites);
Sites[1] = "http://www.dhdzp.com.com~JavaScript Planet|Hundreds of JavaScripts!";
Sites[2] = "http://www.baidu.com/dhtml~dHTML Scripts|Free dHTML Scripts!";
Sites[3] = "http://www.163.com~Altavista|The best search engine";
Sites[4] = "http://www.qq.com~Dynamic Drive|More dHTML Scripts";
function showSites() {
if (w > howmanysites) { w=1; };
var string=Sites[w] + "";
var split1=string.indexOf("~");
var split2=string.indexOf("|");
var url=string.substring(0,split1);
var name=string.substring(split1 + 1,split2);
var word=string.substring(split2 + 1,string.length);
document.form.url.value=url;
document.form.name.value=name;
document.form.word.value=word;
w+=1;
window.setTimeout('showSites()',3000);
}
function visitSite() {
window.location=document.form.url.value;
}
</SCRIPT>
<form name=form>
<table><tr><td align=center>
<input type=button name=name value="Visit" onClick="visitSite()" size=25>
<input type=hidden name=url value="">
<input type=text name=word value="" size=40>
</td></tr></table>
</form>
</center>
<script>
showSites();
</script>
</body>
</html>
希望本文所述對(duì)大家的JavaScript程序設(shè)計(jì)有所幫助。
- JS實(shí)現(xiàn)帶圓弧背景漸變效果的導(dǎo)航菜單代碼
- JS+CSS實(shí)現(xiàn)簡(jiǎn)單的二級(jí)下拉導(dǎo)航菜單效果
- JS實(shí)現(xiàn)黑色大氣的二級(jí)導(dǎo)航菜單效果
- JS實(shí)現(xiàn)帶有抽屜效果的產(chǎn)品類網(wǎng)站多級(jí)導(dǎo)航菜單代碼
- JS+CSS實(shí)現(xiàn)大氣的黑色首頁導(dǎo)航菜單效果代碼
- js實(shí)現(xiàn)的動(dòng)畫導(dǎo)航菜單效果代碼
- 基于dropdown.js實(shí)現(xiàn)的兩款美觀大氣的二級(jí)導(dǎo)航菜單
- js實(shí)現(xiàn)仿愛微網(wǎng)兩級(jí)導(dǎo)航菜單效果代碼
- JS實(shí)現(xiàn)的簡(jiǎn)潔二級(jí)導(dǎo)航菜單雛形效果
相關(guān)文章
JavaScript數(shù)組對(duì)象賦值用法實(shí)例
這篇文章主要介紹了JavaScript數(shù)組對(duì)象賦值用法,涉及javascript用戶交互及針對(duì)數(shù)組的排序技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08
ES6記錄異步函數(shù)的執(zhí)行時(shí)間詳解
在這篇文章里,我會(huì)實(shí)現(xiàn)一個(gè)可重用的函數(shù)來處理 JavaScript 延時(shí)異步操作。有需要的小伙伴們可以參考借鑒,下面來一起看看。2016-08-08
Express與NodeJs創(chuàng)建服務(wù)器的兩種方法
本文主要介紹了NodeJs創(chuàng)建Web服務(wù)器;Express創(chuàng)建Web服務(wù)器的兩種方法,具有一定的參考價(jià)值,下面跟著小編一起來看下吧2017-02-02
使用JavaScript實(shí)現(xiàn)在頁面中顯示距離2017年中秋節(jié)的天數(shù)
這篇文章主要介紹了 使用JavaScript實(shí)現(xiàn)在頁面中顯示距離2017年中秋節(jié)的天數(shù)的相關(guān)資料,需要的朋友可以參考下2017-09-09
javascript溫習(xí)的一些筆記 基礎(chǔ)常用知識(shí)小結(jié)
在電腦上找到多年前的javascript的一些小筆記,因?yàn)橐獙⒐P記本上面的文件整理一下, 不用的刪除掉, 所以將此篇筆記再發(fā)布一下,存檔到自己的博客吧, 電腦上的文件就刪除了2011-06-06

