Ik ben pas beginnend met HTML. Ik wil een menu bouwen met onderstaand script, dat ik op internet gevonden heb. Het is een menu met "hoofdknoppen", die vervolgens uitklappen met daaronder een aantal 'subknoppen". Deze twee wil ik graag laten verschillen van opmaak.
Echter, soms wil ik de uitklappende subknoppen gebruiken, soms ook niet. Maar ik kan maar een style instellen voor mijn hyperlinks. Dus ofwel de hyperlinks van mijn subknoppen hebben de jusite opmaak, of de hoofdknoppen. Hoe kan ik dit oplossen?
Script:
<html>
<head>
<style type="text/css">
.menutitle{
cursor
ointer;
margin-bottom: 0px;
background-color:#FFFF99;
color:#008000;
width:140px;
padding:2px;
text-align:center;
font-weight:bold;
font-family:'Arial',Arial;
font-size: small
}
.submenu{
cursor
ointer;
margin-bottom: 0px;
background-color:#FFFF99;
color:#008000;
width:140px;
text-align:center;
font-family:'Arial',Arial;
font-weight:normal;
font-size: x-small
}
A:link {
cursor
ointer;
margin-bottom: 0px;
background-color:#FFFF99;
color:#008000;
width:140px;
padding:2px;
text-align:center;
text-decoration:none;
font-weight:normal;
font-family:'Arial',Arial;
font-size: x-small
}
A:visited {
cursor
ointer;
margin-bottom: 0px;
background-color:#FFFF99;
color:#008000;
width:140px;
padding:2px;
text-align:center;
text-decoration:none;
font-weight:normal;
font-family:'Arial',Arial;
font-size: x-small
}
A:active {
cursor
ointer;
margin-bottom: 0px;
background-color:#FFFF00;
color:#008000;
width:140px;
padding:2px;
text-align:center;
text-decoration:none;
font-weight:normal;
font-family:'Arial',Arial;
font-size: x-small
}
A:hover {
cursor
ointer;
margin-bottom: 0px;
background-color:#FFFF99;
color:#008000;
width:140px;
padding:2px;
text-align:center;
text-decoration:none;
font-weight:normal;
font-family:'Arial',Arial;
font-size: x-small
}
</style>
<script type="text/javascript">
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}
function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span");
if(el.style.display != "block"){
for (var i=0; i<ar.length; i++){
if (ar.className=="submenu")
ar.style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}
</script>
</head>
<body>
<div id="masterdiv">
<div class="menutitle"><a href="../vieringen/actueel.htm" target="onder"
onmouseover="this.style.backgroundColor='#FFFF00';"
onmouseout="this.style.backgroundColor='#FFFF99';">Contact</a></div>
<div class="menutitle"
onmouseover="this.style.backgroundColor='#FFFF00';"
onmouseout="this.style.backgroundColor='#FFFF99';"
onclick="SwitchMenu('sub_route')">Routebeschrijving</div>
<span class="submenu" id="sub_route">
<a href="../route/auto.htm" target="onder"
onmouseover="this.style.backgroundColor='#FFFF00';"
onmouseout="this.style.backgroundColor='#FFFF99';">Per Auto</a><br />
<a href="../route/fiets.htm" target="onder"
onmouseover="this.style.backgroundColor='#FFFF00';"
onmouseout="this.style.backgroundColor='#FFFF99';">Per Fiets</a>
<a href="../route/ov.htm" target="onder"
onmouseover="this.style.backgroundColor='#FFFF00';"
onmouseout="this.style.backgroundColor='#FFFF99';">Per Trein</a>
</span>
</div>
</body>
</html>
Echter, soms wil ik de uitklappende subknoppen gebruiken, soms ook niet. Maar ik kan maar een style instellen voor mijn hyperlinks. Dus ofwel de hyperlinks van mijn subknoppen hebben de jusite opmaak, of de hoofdknoppen. Hoe kan ik dit oplossen?
Script:
<html>
<head>
<style type="text/css">
.menutitle{
cursor

margin-bottom: 0px;
background-color:#FFFF99;
color:#008000;
width:140px;
padding:2px;
text-align:center;
font-weight:bold;
font-family:'Arial',Arial;
font-size: small
}
.submenu{
cursor

margin-bottom: 0px;
background-color:#FFFF99;
color:#008000;
width:140px;
text-align:center;
font-family:'Arial',Arial;
font-weight:normal;
font-size: x-small
}
A:link {
cursor

margin-bottom: 0px;
background-color:#FFFF99;
color:#008000;
width:140px;
padding:2px;
text-align:center;
text-decoration:none;
font-weight:normal;
font-family:'Arial',Arial;
font-size: x-small
}
A:visited {
cursor

margin-bottom: 0px;
background-color:#FFFF99;
color:#008000;
width:140px;
padding:2px;
text-align:center;
text-decoration:none;
font-weight:normal;
font-family:'Arial',Arial;
font-size: x-small
}
A:active {
cursor

margin-bottom: 0px;
background-color:#FFFF00;
color:#008000;
width:140px;
padding:2px;
text-align:center;
text-decoration:none;
font-weight:normal;
font-family:'Arial',Arial;
font-size: x-small
}
A:hover {
cursor

margin-bottom: 0px;
background-color:#FFFF99;
color:#008000;
width:140px;
padding:2px;
text-align:center;
text-decoration:none;
font-weight:normal;
font-family:'Arial',Arial;
font-size: x-small
}
</style>
<script type="text/javascript">
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}
function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span");
if(el.style.display != "block"){
for (var i=0; i<ar.length; i++){
if (ar.className=="submenu")
ar.style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}
</script>
</head>
<body>
<div id="masterdiv">
<div class="menutitle"><a href="../vieringen/actueel.htm" target="onder"
onmouseover="this.style.backgroundColor='#FFFF00';"
onmouseout="this.style.backgroundColor='#FFFF99';">Contact</a></div>
<div class="menutitle"
onmouseover="this.style.backgroundColor='#FFFF00';"
onmouseout="this.style.backgroundColor='#FFFF99';"
onclick="SwitchMenu('sub_route')">Routebeschrijving</div>
<span class="submenu" id="sub_route">
<a href="../route/auto.htm" target="onder"
onmouseover="this.style.backgroundColor='#FFFF00';"
onmouseout="this.style.backgroundColor='#FFFF99';">Per Auto</a><br />
<a href="../route/fiets.htm" target="onder"
onmouseover="this.style.backgroundColor='#FFFF00';"
onmouseout="this.style.backgroundColor='#FFFF99';">Per Fiets</a>
<a href="../route/ov.htm" target="onder"
onmouseover="this.style.backgroundColor='#FFFF00';"
onmouseout="this.style.backgroundColor='#FFFF99';">Per Trein</a>
</span>
</div>
</body>
</html>