Merhaba arkadaşlar internette bulduğum menü kodlarını dw da çalıştırmaya çalışıyorum ama aynı sonucu alamıyorum. Lütfen acil yardım
Yapmak istediğim menü linki: https://www.456bereastreet.com/lab/accessible-expanding-collapsing-menu/
Kodlar:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
// JavaScript Document
var toggleMenu = {
init : function(sContainerClass, sHiddenClass) {
if (!document.getElementById || !document.createTextNode) {return;} // Check for DOM support
var arrMenus = this.getElementsByClassName(document, 'ul', sContainerClass); // Find all menus
var arrSubMenus, oSubMenu, oLink;
for (var i = 0; i < arrMenus.length; i++) { // In each menu...
arrSubMenus = arrMenus.getElementsByTagName('ul'); // ...find all sub menus
for (var j = 0; j < arrSubMenus.length; j++) { // For each sub menu...
oSubMenu = arrSubMenus[j];
oLink = oSubMenu.parentNode.getElementsByTagName('a')[0]; // ...find the link that toggles it...
oLink.onclick = function(){toggleMenu.toggle(this.parentNode.getElementsByTagName('ul')[0], sHiddenClass); return false;} // ... add an event handler to the link...
this.toggle(oSubMenu, sHiddenClass); // ... and hide the sub menu
}
}
},
toggle : function(el, sHiddenClass) {
var oRegExp = new RegExp("(^|\\s)" + sHiddenClass + "(\\s|$)");
el.className = (oRegExp.test(el.className)) ? el.className.replace(oRegExp, '') : el.className + ' ' + sHiddenClass; // Add or remove the class name that hides the element
},
/* addEvent and getElementsByClassName functions omitted for brevity */
}
// Initialise the menu
toggleMenu.addEvent(window, 'load', function(){toggleMenu.init('menu','hidden');});
/*CSS */
.menu,
.menu ul {
margin:0;
padding:0;
list-style:none;
}
.menu {width:150px;}
.menu li {
margin:0;
padding:0;
margin-bottom:1px;
}
.menu a {
display:block;
padding:2px 5px;
color:#000;
background: #216BC7;
text-decoration:none;
}
.menu a:hover {background: #4584CF}
.menu ul li {padding-left:15px;}
.menu ul a {background: #78C2EB}
.hidden {display:none;}
</style>
</head>
<body>
<ul class="menu">
<li><a href="#">Category 1</a>
<ul>
<li><a href="#">Submenu 1a</a></li>
<li><a href="#">Submenu 1b</a></li>
</ul>
</li>
<li><a href="#">Category 2</a>
<ul>
<li><a href="#">Submenu 2a</a></li>
<li><a href="#">Submenu 2b</a></li>
</ul>
</li>
<li><a href="#">Category 3</a>
<ul>
<li><a href="#">Submenu 3a</a></li>
<li><a href="#">Submenu 3b</a></li>
</ul>
</li>
</ul>
</body>
</html>
Yapmak istediğim menü linki: https://www.456bereastreet.com/lab/accessible-expanding-collapsing-menu/
Kodlar:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
// JavaScript Document
var toggleMenu = {
init : function(sContainerClass, sHiddenClass) {
if (!document.getElementById || !document.createTextNode) {return;} // Check for DOM support
var arrMenus = this.getElementsByClassName(document, 'ul', sContainerClass); // Find all menus
var arrSubMenus, oSubMenu, oLink;
for (var i = 0; i < arrMenus.length; i++) { // In each menu...
arrSubMenus = arrMenus.getElementsByTagName('ul'); // ...find all sub menus
for (var j = 0; j < arrSubMenus.length; j++) { // For each sub menu...
oSubMenu = arrSubMenus[j];
oLink = oSubMenu.parentNode.getElementsByTagName('a')[0]; // ...find the link that toggles it...
oLink.onclick = function(){toggleMenu.toggle(this.parentNode.getElementsByTagName('ul')[0], sHiddenClass); return false;} // ... add an event handler to the link...
this.toggle(oSubMenu, sHiddenClass); // ... and hide the sub menu
}
}
},
toggle : function(el, sHiddenClass) {
var oRegExp = new RegExp("(^|\\s)" + sHiddenClass + "(\\s|$)");
el.className = (oRegExp.test(el.className)) ? el.className.replace(oRegExp, '') : el.className + ' ' + sHiddenClass; // Add or remove the class name that hides the element
},
/* addEvent and getElementsByClassName functions omitted for brevity */
}
// Initialise the menu
toggleMenu.addEvent(window, 'load', function(){toggleMenu.init('menu','hidden');});
/*CSS */
.menu,
.menu ul {
margin:0;
padding:0;
list-style:none;
}
.menu {width:150px;}
.menu li {
margin:0;
padding:0;
margin-bottom:1px;
}
.menu a {
display:block;
padding:2px 5px;
color:#000;
background: #216BC7;
text-decoration:none;
}
.menu a:hover {background: #4584CF}
.menu ul li {padding-left:15px;}
.menu ul a {background: #78C2EB}
.hidden {display:none;}
</style>
</head>
<body>
<ul class="menu">
<li><a href="#">Category 1</a>
<ul>
<li><a href="#">Submenu 1a</a></li>
<li><a href="#">Submenu 1b</a></li>
</ul>
</li>
<li><a href="#">Category 2</a>
<ul>
<li><a href="#">Submenu 2a</a></li>
<li><a href="#">Submenu 2b</a></li>
</ul>
</li>
<li><a href="#">Category 3</a>
<ul>
<li><a href="#">Submenu 3a</a></li>
<li><a href="#">Submenu 3b</a></li>
</ul>
</li>
</ul>
</body>
</html>