Hi all.
I have copied the following source code from the web but am struggling to understand it.
<SCRIPT LANGUAGE=Javascript>
<!--
function inCell(cell, newcolor) {
if (!cell.contains(event.fromElement)) {
cell.bgColor = newcolor;
}
}
function outCell(cell, newcolor) {
if (!cell.contains(event.toElement)) {
cell.bgColor = newcolor;
}
}
//-->
</SCRIPT>
The calls are made from <td ... onmouseover="inCell(this,"red")"> and <td ... onmouseout="inCell(this,"blue"), which I understand although I can't find the keyword "this" in any of the Javascript documentation. The ! symbol in each function is documented as meaning "not", which is fine.
What is .contains()? There is no reference to it in the rest of the source code. Similarly, there is no reference either to event or to .fromElement or .toElement. What are event, fromElement and toElement?
Is everything within the "if" JavaScript? Or is there CSS there?
I really can't follow this. I hope someone can explain it all.
Thanks a lot.
Russell.
I have copied the following source code from the web but am struggling to understand it.
<SCRIPT LANGUAGE=Javascript>
<!--
function inCell(cell, newcolor) {
if (!cell.contains(event.fromElement)) {
cell.bgColor = newcolor;
}
}
function outCell(cell, newcolor) {
if (!cell.contains(event.toElement)) {
cell.bgColor = newcolor;
}
}
//-->
</SCRIPT>
The calls are made from <td ... onmouseover="inCell(this,"red")"> and <td ... onmouseout="inCell(this,"blue"), which I understand although I can't find the keyword "this" in any of the Javascript documentation. The ! symbol in each function is documented as meaning "not", which is fine.
What is .contains()? There is no reference to it in the rest of the source code. Similarly, there is no reference either to event or to .fromElement or .toElement. What are event, fromElement and toElement?
Is everything within the "if" JavaScript? Or is there CSS there?
I really can't follow this. I hope someone can explain it all.
Thanks a lot.
Russell.
Comment