Forum Moderators: open
var state = 'none';
function showhide(layer_ref) {
if (state == 'block') {
state = 'none';
}
else {
state = 'block';
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.display = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].display = state;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
hza.style.display = state;
}
}
and this is the menu:
<div id="klick"><a tabindex="01" href="index.html">presentation</a><br />
<a tabindex="02" href="#" onclick="showhide('gallery');this.blur()">galleries</a><br />
<div id="gallery" style="display:none; margin-left:8px;"><span class="text">¬ <a tabindex="03" href="create.html">created pictures</a><br />
¬ <a tabindex="04" href="photos.html">photos</a></span></div>
<a tabindex="05" href="online.html">life online</a><br />
<a tabindex="06" href="links.html">links</a></div>
Anyone got any idea? :)
<HTML>
<Head>
<Script Language=JavaScript>
var state = 'none';
function toggle(ID) {
if (state == 'block'){state = 'none'}
else {state = 'block'}
document.getElementById(ID).style.display = state;
}
</Script>
</Head>
<Body>
<a href="index.html">presentation</a><br>
<a href=javascript:toggle('gallery')>galleries</a><br>
<div id="gallery" style="display:none; margin-left:8px;">
<a href="create.html"> created pictures </a><br>
<a href="photos.html"> photos </a>
</div>
<a href="online.html"> life online </a><br>
<a href="links.html"> links </a>
</Body>
</HTML>
Press tab: Go to presentation
Press tab again: Go to galleries
Press tab again: Open layer (submenu) gallery, go to created pictures
Press tab again: Go to photos
Press tab again: Close layer (submenu) gallery, go to life online
Press tab again: Go to links
Thanks for the better looking code though :)
--------- Main page ------------
<HTML>
<Head>
<Script Language=JavaScript>
var tourWindow = "";
function startTour(nextPg){
window.opener = self;
tourWindow = window.open(nextPg);
}
function getNextPg(nextPg){
tourWindow.location.replace(nextPg);
}
</Script>
</Head>
<Body>
<br><br><br>
<center>
This is the main page
<br><br>
<input type=button value='Start' onClick="startTour('index.html')">
</center>
</Body>
</HTML>
-------------- Index.html -------------
<HTML>
<Head>
<Script Language=JavaScript></Script>
</Head>
<Body>
<center>
This is the content in the Index page
<br>
<br>
<input type=button value='Next' onClick="opener.getNextPg('create.html')"
</center>
</Body>
</HTML>
-------------- Create.html -------------
<HTML>
<Head>
<Script Language=JavaScript></Script>
</Head>
<Body>
<center>
This is the content in the Create page
<br>
<br>
<input type=button value='Next' onClick="opener.getNextPg('photos.html')"
</center>
</Body>
</HTML>
<a href="index.html">presentation</a><br>
<a tabindex="02" href="#" onfocus="toggle('gallery')">galleries</a><br>
<div id="gallery" style="display:none; margin-left:8px;">
<a href="create.html"> created pictures </a><br>
<a href="photos.html"> photos </a>
</div>
<a href="online.html"> life online </a><br>
<a href="links.html"> links </a>
Thanks forthe help! :)
<HTML>
<Head>
<Script Language=JavaScript>
function toggle(tab){
if (tab == 'gallery'){gallery.style.display = ''}
if (tab == 'life'){gallery.style.display = 'none'}
}
function setFocus(){
present.focus();
}
window.onload=setFocus;
</Script>
</Head>
<Body>
<a href="index.html" tabindex=1 id=present> presentation </a><br>
<a tabindex=2 href="#" onfocus="toggle('gallery')"> galleries </a><br>
<div id=gallery style="display:none; margin-left:8px;">
<a href="create.html" tabindex=3> created pictures </a><br>
<a href="photos.html" tabindex=4> photos </a>
</div>
<a href="online.html" tabindex=5 onfocus="toggle('life')"> life online </a><br>
<a href="links.html" tablindex=6> links </a>
</Body>
</HTML>
<HTML>
<Head>
<Script Language=JavaScript>
function toggle(tab){
if (tab == 'gallery'){gallery.style.display = ''}
if (tab == 'life'){gallery.style.display = 'none'}
}
function setFocus(){
present.focus();
}
window.onload=setFocus;
</Script>
</Head>
<Body>
<a href="index.html" tabindex=1 id=present> presentation </a><br>
<a tabindex=2 href="#" onfocus="toggle('gallery')"> galleries </a><br>
<div id=gallery style="display:none; margin-left:8px;">
<a href="create.html" tabindex=3> created pictures </a><br>
<a href="photos.html" tabindex=4> photos </a>
</div>
<a href="online.html" tabindex=5 onfocus="toggle('life')"> life online </a><br>
<a href="links.html" tablindex=6 onblur="setFocus()"> links </a>
</Body>
</HTML>
The function contains an array of all the elements that need to be toggled you can have as many as you like just put them in the menu_items array, between quotes seperated by commas.
function menu(the_element)
{
var menu_items = ["links","online","photos","gallery","index"];
for (var i=0;i<menu_items.length;i++) {
a = document.getElementById(menu_items[i]).style
if (menu_items[i] == the_element) {
a.display = ''
} else {
a.display = 'none'
}
}
}
and use a anchor tag like this for your menu
<a href="#"
onClick="menu('photos');">Create Photos</a>
Hope someone finds this useful