PDA

View Full Version : IE <--> Mozilla >.<


HappyTomato
12-05-2002, 08:59 PM
Dear all:

We've got a page we'd like to run on both IE and Mozzila, it's three DIV elements with checkboxes and when the boxes are checked the background color will change individually.
The following code is one of the DIV elements, however it only works on IE but not Mozilla.... is there any cross-browser things that we need to know? or where can we find out more ....
Any help is appreciated! :)

<div style="background:yellow;color:black;">
<input type="checkbox" name="food1" value="apple" onClick="Javascript:
if (this.checked)
this.parentElement.style.background='#99CCFF';
else
this.parentElement.style.background='yellow';
return true;">
apple</div>


Bo & Vic :o

Roy Sinclair
12-05-2002, 09:58 PM
<div id="d1" style="background:yellow;color:black;">
<input type="checkbox" name="food1" value="apple" onClick="Javascript:
if (this.checked)
document.getElementById('d1').style.background='#99CCFF';
else
document.getElementById('d1').style.background='yellow';
return true;">
apple</div>


The parentElement isn't the same between the two browsers.

HappyTomato
12-05-2002, 10:11 PM
Thank you Roy, our page works now! on BOTH IE and Moz!!!!

jkd
12-05-2002, 11:09 PM
Originally posted by Roy Sinclair
The parentElement isn't the same between the two browsers.

Namely because parentElement doesn't exist in Moz.

However, they both share the same parentNode. Replacing parentElement with parentNode would be a better way of going about this, and would also require basically no modification to the original code.