knuckledog Posted January 25, 2008 Share Posted January 25, 2008 I have script that is going to be employed on a glossary page. The idea is that the user clicks on a Japanese word (within a scrolldown list) and underneath the word appears the English translation. The script at the moment reads as follows (in the header): <script language="javascript"> <!-- 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; } } //--> </script> The script in the body reads like this <p><a href="#" onclick="showhide('div1');">show/hide me</a></p> <div id="div1" style="display: none;">This is the content</div><p><a href="#" onclick="showhide('div2');">show/hide me</a></p> <div id="div2" style="display: none;">This is the content</div> It actually works after a fashion but I have one major problem. The problem is that once you click on one term (one highlighted word) all the terms change color (as if the user has opened and closed them all). If somebody could offer me some feedback on how to correct this problem (please explain things easily because I am not that Javascript literate), I would greatly appreciate it. RegardsKnuckle Link to comment Share on other sites More sharing options...
Ingolme Posted January 25, 2008 Share Posted January 25, 2008 That's because the URL "#" is now in the user's history list and all the links are pointing to it.I'm not sure if it will be effective, but try this:<p><a href="javascript: void(0)" onclick="showhide('div1');">show/hide me</a></p><div id="div1" style="display: none;">This is the content</div><p><a href="javascript: void(0)" onclick="showhide('div2');">show/hide me</a></p><div id="div2" style="display: none;">This is the content</div> Link to comment Share on other sites More sharing options...
knuckledog Posted January 25, 2008 Author Share Posted January 25, 2008 Hey it works Baby! Thanks a lot!!!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.