Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-28-2004, 08:19 PM   PM User | #1
CompGeek01
New to the CF scene

 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
CompGeek01 is an unknown quantity at this point
Javascript IE compatibility problem

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.

Code:
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:
Code:
<tr class="norm" id="4" onMouseOver="over('4', 'on')" onMouseOut="over('4','off')" onclick="click('4')">
CompGeek01 is offline   Reply With Quote
Old 04-28-2004, 08:27 PM   PM User | #2
Vladdy
Senior Coder

 
Join Date: Jun 2002
Location: Nashua, NH
Posts: 1,724
Thanks: 0
Thanked 0 Times in 0 Posts
Vladdy is an unknown quantity at this point
In Moz you can do simple CSS, for IE here is my fix:
http://www.vladdy.net/Demos/IEPseudoClassesFix.html
__________________
Vladdy | KL
"Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"
Vladdy is offline   Reply With Quote
Old 04-28-2004, 08:35 PM   PM User | #3
CompGeek01
New to the CF scene

 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
CompGeek01 is an unknown quantity at this point
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.
CompGeek01 is offline   Reply With Quote
Old 04-28-2004, 09:05 PM   PM User | #4
Vladdy
Senior Coder

 
Join Date: Jun 2002
Location: Nashua, NH
Posts: 1,724
Thanks: 0
Thanked 0 Times in 0 Posts
Vladdy is an unknown quantity at this point
Code:
<tr onclick="highlight(this);">
Code:
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;
    return;
  }
__________________
Vladdy | KL
"Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"
Vladdy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:04 PM.


Advertisement
Log in to turn off these ads.