Entry
How do I attatch an onclick event to an image in NS4 without using a href tag, and will it still work in IE4+
Apr 30th, 2001 04:54
Colin Fraser, Mark Fritz,
The only way of stimulating a user to cause an event is to generate a
mouse click or a keypress, or a mouse move. You can use the body tag :
<body onClick="dothis()" onMouseMove="doThat()"
onKeyPress="doSomething()";msDoSomethingElse() bgcolor="#ffffff">
This may prove unwieldy for what you require in relation to an image so
try this instead :
<a href="javascript:void" onMouseOver="dothatThing()"
onClick="dothisthing()"><img src="myimage.gif" border=0></a>
The short answer is that there are few objects you can use to generate
an event, the <a href="..> is probably the most obvious to use.