Forum Moderators: open

Message Too Old, No Replies

dhtml problems

not working for me :-(

         

macrost

4:05 pm on Jun 17, 2004 (gmt 0)

10+ Year Member



Ok, it's been a while since I have done this. I just want to hide a table row until a link is clicked, then on the link have an onclick handler that will show the div.

However the div is showing, regardless. Here is my js.


<SCRIPT TYPE="text/javascript">
<!--
// This script is intended for use with a minimum of Netscape 4 or IE 4.
var ns4 = (document.layers);
var ie4 = (document.all &&!document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

function show(id){
// Netscape 4
if(ns4){
document.layers[id].visibility = "show";
}
// Explorer 4
else if(ie4){
document.all[id].style.visibility = "visible";
}
// W3C - Explorer 5+ and Netscape 6+
else if(ie5 ¦¦ ns6){
document.getElementById(id).style.visibility = "visible";
}
}

function hide(id){
// Netscape 4
if(ns4){
document.layers[id].visibility = "hide";
}
// Explorer 4
else if(ie4){
document.all[id].style.visibility = "hidden";
}
// W3C - Explorer 5+ and Netscape 6+
else if(ie5 ¦¦ ns6){
document.getElementById(id).style.visibility = "hidden";
}
}
//-->
</SCRIPT>

Now my table row


<div id="loading">
<tr>
<td colspan="3" align="center" style="background-color:red; color:black;">Loading... Please wait...</td>
</tr>
</div>

Now i have tried a body onload calling the function hide('loading'); and that doesn't work. Neither does adding a script block at the end of the page calling the function.
Any ideas?

DrDoc

4:44 pm on Jun 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It probably doesn't work because the markup is broken. You are missing the <table> tags... Or, is it just a row you want to hide? If so, you need to assign the ID to the <tr> instead. Also, you should probably toggle the
display
property instead, since making something invisible will still take up space on the page.

macrost

5:12 pm on Jun 17, 2004 (gmt 0)

10+ Year Member



haha, that was the ticket!
Thanks DrDoc.

macrost

5:19 pm on Jun 17, 2004 (gmt 0)

10+ Year Member



DrDoc,
I was wondering how gmail does their little loading thing that appears in the upper right corner of the screen.
I think it might follow depending how far down the page your are, but I don't know about that. I don't have enough mail to test that one out!

<added>
Ok I have discovered z-index... now it works for about half of the page down. I guess a little more experimenting is in order!
</added>