Forum Moderators: open
You could try
if(document.getElementsByTagName("img")[0].onclick) alert("Test"); This would test for the existence of an onclick event handler on the first image on the page (I think). You might need to use onClick - I can't remember.
<added>
You can also use the document.images array too, I think.
</added.
Kaled.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset:utf-8">
<title></title>
<script type="text/javascript">
function attachImgEventHandlers()
{
var imgNodes = document.getElementsByTagName("img");
for( var i = 0; i < imgNodes.length; i++ )
{
imgNodes[i].onclick = function(){alert("test");};
}
}
</script>
</head>
<body onload="attachImgEventHandlers();">
<img src="x.gif" alt="x">
<img src="y.gif" alt="y">
</body>
</html>