...

View Full Version : test HTML object for event handler



sbq
07-29-2006, 11:37 PM
We have the following snippet of code:


function buildLink(id, value) {
var url = parent.modelGet(id)
var el = document.getElementById(id)
... code that adds innerText to el
if (el.onchange)
el.onchange()

}

I'm getting an error in IE 7 Beta 3 for the line in red, claiming the "object does not support this property or method". The claim is true, but the point of the if-test in the line above is to insure we only call onchange() for objects that have an onchange() handler.

This code has worked for us for IE6, Firefox, etc. Is this a bug in IE 7 Beta 3? Or are we misusing that if-test?

glenngv
07-30-2006, 05:26 AM
Try alerting its type if it indeed returns a function pointer.

alert(typeof el.onchange)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum