View Full Version : Javascript IE compatibility problem

04-28-2004, 08:19 PM
Might anyone know WHY this script works in Firebird/Opera but does not work in IE based browsers...?

If you need an explination, it's for changing the colors of table rows when moused over..based on two CSS classes (over and norm..) which change the look of the row. Basically, what doesn't work is the click function..the over works perfect. I think it might have something to do with the array.

var marked = new Array();

function over(obj, state) {
if ( state == 'on' && marked[obj] != true ) {
document.getElementById(obj).className = 'over';
} else if ( marked[obj] != true ) {
document.getElementById(obj).className = 'norm';

function click(obj) {
if ( marked[obj] != true ) {
marked[obj] = true;
document.getElementById(obj).className = 'over';
} else {
marked[obj] = false;
document.getElementById(obj).className = 'norm';

Here is an example of how it could be implemented:

<tr class="norm" id="4" onMouseOver="over('4', 'on')" onMouseOut="over('4','off')" onclick="click('4')">

04-28-2004, 08:27 PM
In Moz you can do simple CSS, for IE here is my fix:

04-28-2004, 08:35 PM
I understand that. Thank you for the alternative..

The mouseover isn't the problem. I want the row to stay hilighted when it's clicked...via storage in an array as I am doing. Your option still gives me no way to accomplish this in Javascript in IE browsers.

04-28-2004, 09:05 PM
<tr onclick="highlight(this);">

function highlight(row)
{ //assuming that all rows are children of the same element (tbody)
if(row.parentNode.highlightedRow) row.parentNode.highlightedRow.className = '';
row.className = 'highlight';
row.parentNode.highlightedRow = row;

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum