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>