I’m using the following code to override a JavaScript function named dismissRelatedLookupPopup(). In Firefox, this works without a problem (displays the alert once and runs my code), but in Internet Explorer 7 it results in an infinite loop displaying the alert() forever. I’m doing this because I don’t control the code where dismissRelatedLookupPopup() is called, and I’d like to add a hook of my own when it’s called. Is there a cross-browser way to do this?
old_dismissRelatedLookupPopup = dismissRelatedLookupPopup; dismissRelatedLookupPopup = function dismissRelatedLookupPopup(win, chosenId) { alert('i hate ie'); old_dismissRelatedLookupPopup(win,chosenId); var name = windowname_to_id(win.name); var elem = document.getElementById(name); elem.onchange(); }
Note: It’s my understanding that when JavaScript updates the value of an element directly (ie. elem.value = 1) that the onchange() event of that element will not fire. That is why I’m including this code to force the onchange() when the value is updated.
I’m pretty sure that changing this line:
to
will cure what ails ya.