1、前台實現長鏈接的Js代碼方法代碼。
注意事項:
javascript腳本語言同其他語言一樣,有它自身的基本數據類型,表達式和算術運算符及程序的基本程序框架。Javascript提供了四種基本的數據類型和兩種特殊數據類型用來處理數據和文字。而變數提供存放信息的地方,表達式則可以完成較復雜的信息處理。
『貳』 關於下拉菜單的JS代碼
<styletype="巧灶text/css">
mainMenu{
background-color:FFF;/*Backgroundcolorofmainmenu*/
font-family:TrebuchetMS,LucidaSansUnicode,Arial,sans-serif;/*Fontsofmainmenuitems*/
font-size:1.2em;/*Fontsizeofmainmenuitems*/
border-bottom:1pxsolid000000;/*Bottomborderofmainmenu*/
height:30px;/*Heightofmainmenu*/
position:relative;/*Don*/
visibility:hidden;
}
mainMenua{
padding-left:20px;/**/
padding-right:20px;/**/
font-weight:bold;
/*Don'tchangethesetwooptions*/
position:absolute;
bottom:-1px;
}
submenu{
font-family:TrebuchetMS,LucidaSansUnicode,Arial,sans-serif;/*Fontofsubmenuitems*/
background-color:E2EBED;/*Backgroundcolorofsubmenuitems*/
visibility:hidden;
width:778px;/*Don'tchangethisoption*/
}
html>bodyclearmenu{/**/
margin-bottom:2px;
}
submenudiv{
white-space:nowrap;/*Don'tchangethisoption*/
}
/*
*/
mainMenu.activeMenuItem{
/*Borderoptions*/
border-left:1pxsolid000000;
border-top:1pxsolid000000;
border-right:1pxsolid000000;
background-color:E2EBED;/*Backgroundcolor*/
cursor:pointer;/**/
}
/*
*/
mainMenu.inactiveMenuItem{
color:000;/*Textcolor*/
cursor:pointer;/**/
}
submenua{
text-decoration:none;/*Nounderlineonsubmenuitems-usetext-decoration:underline;*/
padding-left:5px;/**/
padding-right:5px;/**/
color:000;/*Textcolor*/
}
submenua:hover{
color:FF0000;/**/
}
</style>孝臘扮
<scripttype="text/javascript">局乎
//morejavascriptfrom/support/analyzer/manual/html/General/CookiesJavaScript.htm
*/
functionGet_Cookie(name){
varstart=document.cookie.indexOf(name+"=");
varlen=start+name.length+1;
if((!start)&&(name!=document.cookie.substring(0,name.length)))returnnull;
if(start==-1)returnnull;
varend=document.cookie.indexOf(";",len);
if(end==-1)end=document.cookie.length;
returnunescape(document.cookie.substring(len,end));
}
//
functionSet_Cookie(name,value,expires,path,domain,secure){
expires=expires*60*60*24*1000;
vartoday=newDate();
varexpires_date=newDate(today.getTime()+(expires));
varcookieString=name+"="+escape(value)+
((expires)?";expires="+expires_date.toGMTString():"")+
((path)?";path="+path:"")+
((domain)?";domain="+domain:"")+
((secure)?";secure":"");
document.cookie=cookieString;
}
functionshowHide()
{
if(activeMenuItem){
activeMenuItem.className='inactiveMenuItem'
vartheId=activeMenuItem.id.replace(/[^d]/g,'');
document.getElementById('submenu_'+theId).style.display='none'
}
activeMenuItem=this;
this.className='activeMenuItem'
vartheId=this.id.replace(/[^d]/g,'');
document.getElementById('submenu_'+theId).style.display='block'
if(rememberActiveTabByCookie){
Set_Cookie('dhtmlgoodies_tab_menu_tabIndex','index:'+(theId-1),100);
}
}
functioninitMenu()
{
varmainMenuObj=document.getElementById('mainMenu');
varsubMenuObj=document.getElementById('submenu');//DDaddedline
mainMenuObj.style.visibility=subMenuObj.style.visibility="visible"//DDaddedline
varmenuItems=mainMenuObj.getElementsByTagName('A');
if(document.all){
mainMenuObj.style.visibility='hidden'
document.getElementById('submenu').style.visibility='hidden'
}
if(rememberActiveTabByCookie){
varcookieValue=Get_Cookie('dhtmlgoodies_tab_menu_tabIndex')+''
cookieValue=cookieValue.replace(/[^d]/g,'');
if(cookieValue.length>0&&cookieValue<menuItems.length){
activeTabIndex=cookieValue/1;
}
}
varcurrentLeftPos=15;
for(varno=0;no<menuItems.length;no++){
if(activateSubOnClick)menuItems[no].onclick=showHide;elsemenuItems[no].onmouseover=showHide;
menuItems[no].id='mainMenuItem'+(no+1);
menuItems[no].style.left=currentLeftPos+'px'
currentLeftPos=currentLeftPos+menuItems[no].offsetWidth+topMenuSpacer;
if(no==activeTabIndex){
menuItems[no].className='activeMenuItem'
activeMenuItem=menuItems[no];
}elsemenuItems[no].className='inactiveMenuItem'
if(!document.all)menuItems[no].style.bottom='-1px'
}
varmainMenuLinks=mainMenuObj.getElementsByTagName('A');
varsubCounter=1;
varparentWidth=mainMenuObj.offsetWidth;
while(document.getElementById('submenu_'+subCounter)){
varsubItem=document.getElementById('submenu_'+subCounter);
if(leftAlignSubItems){
//Noaction
}else{
varleftPos=mainMenuLinks[subCounter-1].offsetLeft;
document.getElementById('submenu_'+subCounter).style.paddingLeft=leftPos+'px'
subItem.style.position='absolute'
if(subItem.offsetWidth>parentWidth){
leftPos=leftPos-Math.max(0,subItem.offsetWidth-parentWidth);
}
subItem.style.paddingLeft=leftPos+'px'
subItem.style.position='static'
}
if(subCounter==(activeTabIndex+1)){
subItem.style.display='block'
}else{
subItem.style.display='none'
}
subCounter++;
}
if(document.all){
mainMenuObj.style.visibility='visible'
document.getElementById('submenu').style.visibility='visible'
}
document.getElementById('submenu').style.display='block'
}
window.onload=initMenu;
</script>
<divid="mainMenu">
<a>網頁特效</a>
<a>插件下載</a>
<a>網路學院</a>
<a>網站聯盟</a>
</div>
<divid="submenu">
<!--Thefirstsubmenu-->
<divid="submenu_1">
<ahref="javascript.asp?type=圖形圖像">圖形圖像</a>
<ahref="javascript.asp?type=滑鼠事件">滑鼠事件</a>
<ahref="javascript.asp?type=時間日期">時間日期</a>
<ahref="javascript.asp?type=導航菜單">導航菜單</a>
<ahref="javascript.asp?type=文字效果">文字效果</a>
<ahref="javascript.asp?type=窗體變化">窗體變化</a>
</div>
<!--Secondsubmenu-->
<divid="submenu_2">
<ahref="plug.asp?type=DreamWeaver插件">DreamWeaver插件</a>
<ahref="plug.asp?type=FireWork插件"FireWork插件</a>
<ahref="plug.asp?type=PhotoShop插件">PhotoShop插件</a>
<ahref="plug.asp?type=FLASH組件">FLASH組件</a>
</div>
<!--Thirdsubmenu-->
<divid="submenu_3">
<ahref="study.asp?type=網頁製作">網頁製作</a>
<ahref="study.asp?type=網路編程">網路編程</a>
<ahref="study.asp?type=圖形圖像">圖形圖像</a>
<ahref="study.asp?type=多媒體製作">多媒體製作</a>
<ahref="study.asp?type=網站建設">網站建設</a>
<ahref="study.asp?type=操作系統">操作系統</a>
</div>
<!--Fourthsubmenu-->
<divid="submenu_4">
<ahref="webmeng_show.asp?type=1">網頁設計</a>
<ahref="webmeng_show.asp?type=2">藝術創作</a>
<ahref="webmeng_show.asp?type=3">電腦網路</a>
<ahref="webmeng_show.asp?type=4">生活休閑</a>
<ahref="webmeng_show.asp?type=5">個性展示</a>
<ahref="webmeng_show.asp?type=6">其它類型</a>
</div>
</div>
<brid="clearmenu"/>
『叄』 PHP 使用JS實現下拉菜單
<script language="javascript">
// JavaScript Document
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
</script>
<style type="text/css">
<!--
body {
font: normal 11px verdana;
}
ul {
margin: 0;
padding: 0;
list-style: none;
width: 150px; /* Width of Menu Items */
border-bottom: 1px solid #ccc;
}
ul li {
position: relative;
}
li ul {
position: absolute;
left: 149px; /* Set 1px less than menu width */
top: 0;
display: none;
}
/* Styles for Menu Items */
ul li a {
display: block;
text-decoration: none;
color: #777;
background: #fff; /* IE6 Bug */
padding: 5px;
border: 1px solid #ccc; /* IE6 Bug */
border-bottom: 0;
}
/* Holly Hack. IE Requirement \*/
* html ul li { float: left; height: 1%; }
* html ul li a { height: 1%; }
/* End */
li:hover ul, li.over ul { display: block; } /* The magic */
-->
</style>
<ul id="nav">
<li><a href="#">Home</a></li>
<li><a href="#">About</a>
<ul>
<li><a href="#">History</a></li>
<li><a href="#">Team</a></li>
<li><a href="#">Offices</a></li>
</ul>
</li>
<li><a href="#">Services</a>
<ul>
<li><a href="#">Web Design</a></li>
<li><a href="#">Internet Marketing</a></li>
<li><a href="#">Hosting</a></li>
<li><a href="#">Domain Names</a></li>
<li><a href="#">Broadband</a></li>
</ul>
</li>
<li><a href="#">Contact Us</a>
<ul>
<li><a href="#">United Kingdom</a></li>
<li><a href="#">France</a></li>
<li><a href="#">USA</a></li>
<li><a href="#">Australia</a></li>
</ul>
</li>
</ul>
『肆』 用js做下拉導航條 當滑鼠指上去顯示 滑鼠移開就隱藏 怎麼做 求代碼
首先結構如下:
<style>.nav>li {width:120px;height:40px;display:inline-block;padding:5px 15px;background:#ddd;text-align:center}.nav li ul {display:none}.subnav li {padding:5px}.nav li:hover .subnav {display:block;background: #e8e8e8}
</style>
<ul class="nav">
<li><a href="">一級菜專單屬1</a>
<ul class="subnav">
<li><a href="">2級菜單</a></li>
<li><a href="">2級菜單</a></li>
</ul>
</li>
<li><a href="">一級菜單2</a>
<li><a href="">一級菜單3</a>
</ul>
『伍』 下拉菜單控制二級下拉菜單顯示與隱藏JS代碼
給你個寫死了的吧,活的你要自己去綁定SQL了。
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>無標題頁</title>
<script type="text/javascript">
function Selcet(){
var select_user = window.document.getElementById("select1");
var select_tao = window.document.getElementById("select2");
var value = select_user.value;
while(select_tao.options.length)
{
select_tao.options[select_tao.options.length -1] = null;
}
if(value==1)
{
select_tao.options.add(new Option("用戶套餐1",1))
}
if(value==2)
{
select_tao.options.add(new Option("用戶套餐2",2))
}
if(value==3)
{
select_tao.options.add(new Option("用戶套餐3",3))
}
if(value==4)
{
select_tao.options.add(new Option("用戶套餐4",4))
}
if(value==0)
{
select_tao.options.add(new Option("用戶套餐1",1))
select_tao.options.add(new Option("用戶套餐2",2))
select_tao.options.add(new Option("用戶套餐3",3))
select_tao.options.add(new Option("用戶套餐4",4))
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
用戶類型: <select id="select1" onchange="Selcet()">
<option value="0">--請選擇--</option>
<option value="1">用戶類型1</option>
<option value="2">用戶類型2</option>
<option value="3">用戶類型3</option>
<option value="4">用戶類型4</option>
</select>
套餐菜單: <select id="select2">
<option value="1">用戶套餐1</option>
<option value="2">用戶套餐2</option>
<option value="3">用戶套餐3</option>
<option value="4">用戶套餐4</option>
</select>
</div>
</form>
</body>
</html>