detecting values for object properties

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?
 
T

Tom

Well I solved my own problem:
thisDiv.style.display = "";

I'm still curious if there's a way to detect valid property assignments
though :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top