wynton_ca
05-22-2003, 01:55 PM
Hey all you js freaks. Im having a problem with a show/hide layer script. The basics - user clicks 'show details', layer opens up, original link changes to 'hide details', user clicks on hide details, the layer goes away and reverts back to 'show details'. I have the script functioning well on IE, however NN is giving me many problems. I thought I might throw it up on here and see if any of you have some suggestions on this. Here it is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>show-hide test</title>
<script>
function toggle_div_inline_display(id) {
var spanObj = document.all.item(id);
var prevStyle = spanObj.style.display;
if (prevStyle == 'none') {
spanObj.style.display = 'inline';
}
else {
spanObj.style.display = 'none';
}
}
function toggle_innertext_display(thisElement,displayedText1,displayedText2) {
if (thisElement.innerText == displayedText1) {
thisElement.innerText = displayedText2;
}
else if (thisElement.innerText == displayedText2) {
thisElement.innerText = displayedText1;
}
else {
thisElement.innerText = displayedText1;
}
}
</script>
</head>
<body>
<a href="javascript:toggle_div_inline_display('1');" onclick="javascript:toggle_innertext_display(this,'Show Details','Hide Details');">Show Details</a>
<br>
<div ID='1' STYLE='display: none' >
this is the content of layer 1<br>
</div>
<a href="javascript:toggle_div_inline_display('2');" onclick="javascript:toggle_innertext_display(this,'Show Details','Hide Details');">Show Details</a>
<br>
<div ID='2' STYLE='display: none' >
this is the content of layer 2
</div>
</body>
</html>
It seems as though NN just doesnt recognize the script at all. Let me know what you think.
thanks!
wynton
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>show-hide test</title>
<script>
function toggle_div_inline_display(id) {
var spanObj = document.all.item(id);
var prevStyle = spanObj.style.display;
if (prevStyle == 'none') {
spanObj.style.display = 'inline';
}
else {
spanObj.style.display = 'none';
}
}
function toggle_innertext_display(thisElement,displayedText1,displayedText2) {
if (thisElement.innerText == displayedText1) {
thisElement.innerText = displayedText2;
}
else if (thisElement.innerText == displayedText2) {
thisElement.innerText = displayedText1;
}
else {
thisElement.innerText = displayedText1;
}
}
</script>
</head>
<body>
<a href="javascript:toggle_div_inline_display('1');" onclick="javascript:toggle_innertext_display(this,'Show Details','Hide Details');">Show Details</a>
<br>
<div ID='1' STYLE='display: none' >
this is the content of layer 1<br>
</div>
<a href="javascript:toggle_div_inline_display('2');" onclick="javascript:toggle_innertext_display(this,'Show Details','Hide Details');">Show Details</a>
<br>
<div ID='2' STYLE='display: none' >
this is the content of layer 2
</div>
</body>
</html>
It seems as though NN just doesnt recognize the script at all. Let me know what you think.
thanks!
wynton