But say I want to make a script that automatically handles the onMouseOver and onMouseOut events, but I want these to be specified in the script itself, not in the link, how would I go about doing that?
I'm not sure I'm making myself clear here... To take an example, say I have a little menu with each menu point being set up as a TD in a table (I know, it's not really tabular information, but it works the best in this case). I then want the background colour of each TD to change on mouse-over. This would of course be very simple to do by simply doing:
<td onmouseover="....." onmouseout=".....">...</td>
But this is so messy and unflexible and annoying...
So I thought I would write a short, simple script that did the same thing - but no luck! I've tried Googling it, but I can't find anything about it, so now I'm asking here...
What I had in mind was something like this:
this.style.backgroundColor = "#B0D0FF";
this.style.backgroundColor = "#FFFFFF";
document.getElementByTagName('td').onMouseOver = switchOn();
document.getElementByTagName('td').onMouseOut = switchOff();
Obviously, this doesn't work or I wouldn't be asking, but you get the idea...
Any way to do that?