DW4取消了“显示弹出菜单”,使很多朋友在制作二级菜单的时候不知道什么简单办法了,我研究了一段了时间,以下代码可行,在IE8/FIREFOX/IE6的浏览器下测试可行,HTML代码和CSS代码分别保存。
该代码只使用了onmouseover、onmouseout两个js代码,简单易用,不用手工编写,直接在DW里面,选中主导航的某个菜单(比如“新闻”),按F9(标签检查器),再按“行为”,再点击“+”,选择“显示-隐藏元素”,在弹出的窗口里选择要显示或隐藏图层的ID(比如“#sub_menu_01”),再点击“显示”或“隐藏”,然后确定就可以了。
HTML代码:
<!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=utf-8" />
<title>无标题文档</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function MM_showHideLayers() { //v9.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3)
with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
<wbr><wbr><wbr> if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }<br><wbr><wbr><wbr> obj.visibility=v; }<br> }<br> //--><br> </script><br> </head></wbr></wbr></wbr></wbr></wbr></wbr>
<body>
<!--外框-->
<div id="wrapper">
<!--主导航-->
<div id="menu">
<ul>
<wbr><wbr><wbr> <li><a href="#" οnmοuseοver="MM_showHideLayers('sub_menu_01','','show');MM_showHideLayers('sub_menu_02','','hide');MM_showHideLayers('sub_menu_03','','hide');MM_showHideLayers('sub_menu_04','','hide');MM_showHideLayers('sub_menu_05','','hide')">首页</a></li><br><wbr><wbr><wbr> <li><a href="#" οnmοuseοver="MM_showHideLayers('sub_menu_02','','show');MM_showHideLayers('sub_menu_01','','hide');MM_showHideLayers('sub_menu_03','','hide');MM_showHideLayers('sub_menu_04','','hide');MM_showHideLayers('sub_menu_05','','hide')">新闻</a></li><br><wbr><wbr><wbr> <li><a href="#" οnmοuseοver="MM_showHideLayers('sub_menu_03','','show');MM_showHideLayers('sub_menu_02','','hide');MM_showHideLayers('sub_menu_01','','hide');MM_showHideLayers('sub_menu_04','','hide');MM_showHideLayers('sub_menu_05','','hide')">简介</a></li><br><wbr><wbr><wbr> <li><a href="#" οnmοuseοver="MM_showHideLayers('sub_menu_04','','show');MM_showHideLayers('sub_menu_02','','hide');MM_showHideLayers('sub_menu_03','','hide');MM_showHideLayers('sub_menu_01','','hide');MM_showHideLayers('sub_menu_05','','hide')">产品</a></li><br><wbr><wbr><wbr> <li><a href="#" οnmοuseοver="MM_showHideLayers('sub_menu_05','','show');MM_showHideLayers('sub_menu_02','','hide');MM_showHideLayers('sub_menu_03','','hide');MM_showHideLayers('sub_menu_04','','hide');MM_showHideLayers('sub_menu_01','','hide')">联系</a></li><br> </ul><br> </div><br> <!--二级菜单--><br> <div id="sub_menu"><br><wbr><wbr> <!--01:对应“首页”--><br> <div id="sub_menu_01"><br><wbr><wbr><wbr> <ul οnmοuseοver="MM_showHideLayers('sub_menu_01','','show')" οnmοuseοut="MM_showHideLayers('sub_menu_01','','hide')"><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">01二级菜单01</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">01二级菜单02</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">01二级菜单03</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">01二级菜单04</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> </ul><br><wbr><wbr><wbr> </div><br><wbr><wbr><wbr> <!--02--><br> <div id="sub_menu_02"><br><wbr><wbr><wbr> <ul οnmοuseοver="MM_showHideLayers('sub_menu_02','','show')" οnmοuseοut="MM_showHideLayers('sub_menu_02','','hide')"><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">02二级菜单01</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">02二级菜单02</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">02二级菜单03</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">02二级菜单04</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> </ul><br><wbr><wbr><wbr> </div><br><wbr><wbr><wbr> <!--03--><br> <div id="sub_menu_03"><br><wbr><wbr><wbr> <ul οnmοuseοver="MM_showHideLayers('sub_menu_03','','show')" οnmοuseοut="MM_showHideLayers('sub_menu_03','','hide')"><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">03二级菜单01</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">03二级菜单02</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">03二级菜单03</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">03二级菜单04</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> </ul><br><wbr><wbr><wbr> </div><br><wbr><wbr><wbr> <!--04--><br> <div id="sub_menu_04"><br><wbr><wbr><wbr> <ul οnmοuseοver="MM_showHideLayers('sub_menu_04','','show')" οnmοuseοut="MM_showHideLayers('sub_menu_04','','hide')"><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">04二级菜单01</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">04二级菜单02</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">04二级菜单03</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> <li><a href="#">04二级菜单04</a></li><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> </ul><br><wbr><wbr><wbr> </div><br><wbr><wbr><wbr> <!--05--><br> <div id="sub_menu_05"><br><wbr><wbr><wbr> <ul οnmοuseοver="MM_showHideLayers('sub_menu_05','','show')" οnmοuseοut="MM_showHideLayers('sub_menu_05','','hide')"><br><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>