T
Tom
I need a little validation script to test whether a certain value for a
property exists or not: specifically, whether the value "table-row" is
a legit value for the style.display property. I'm turning table rows
on and off, and CSS2 supported browsers can use "table-row" as a value
for style.display, but browsers that don't support CSS2 (like IE 6.0)
don't recognize the value "table-row" as being valid (it returns an
error). The alternative is to use "style.display = 'block';", but
browsers that use CSS2 turn the <tr> into a block element, and it loses
the properties of a true <tr> element (i.e. colspan, rowspan become
meaningless). So I need a detection (or something better if this is
sloppy).
Here's what I've got:
<script language="javascript" type="text/javascript">
<!--
function turnRowOff( id ) {
thisDiv = document.getElementById( id );
thisDiv.style.display = "none";
}
function turnRowOn( id ) {
thisDiv = document.getElementById( id );
if ( ??? some code ??? ) {
thisDiv.style.display = "table-row" ;
} else {
thisDiv.style.display = "block" ;
}
}
// -->
</script>
<a href="javascript:turnRowOff('whatever');">turn row on</a>
<table><tr id="whatever" style="display: none;"><td>Now you see
me!</td></tr></table>
Any ideas?
property exists or not: specifically, whether the value "table-row" is
a legit value for the style.display property. I'm turning table rows
on and off, and CSS2 supported browsers can use "table-row" as a value
for style.display, but browsers that don't support CSS2 (like IE 6.0)
don't recognize the value "table-row" as being valid (it returns an
error). The alternative is to use "style.display = 'block';", but
browsers that use CSS2 turn the <tr> into a block element, and it loses
the properties of a true <tr> element (i.e. colspan, rowspan become
meaningless). So I need a detection (or something better if this is
sloppy).
Here's what I've got:
<script language="javascript" type="text/javascript">
<!--
function turnRowOff( id ) {
thisDiv = document.getElementById( id );
thisDiv.style.display = "none";
}
function turnRowOn( id ) {
thisDiv = document.getElementById( id );
if ( ??? some code ??? ) {
thisDiv.style.display = "table-row" ;
} else {
thisDiv.style.display = "block" ;
}
}
// -->
</script>
<a href="javascript:turnRowOff('whatever');">turn row on</a>
<table><tr id="whatever" style="display: none;"><td>Now you see
me!</td></tr></table>
Any ideas?