A browser element has an onpopupshowing attribute, which is a string consisting of several javascript statements.
I want to "override" that bit of javascript.
Were this a function, I'd just assign it to a variable, assign my "overriding" function to the element attribute, and (if need be) call the original function from my overriding one, pretty much like this:
var oldfunc;
function myoverrridingfunc () { my statement; oldfunc(); my other statement; }
oldfunc = element.getAttribute( "onpopupshowing" )
element.setAttribute( "onpopupshowing", myoverrridingfunc );
but element.getAttribute( "onpopupshowing" ) isn't a function, it's a string.
I could use the Function object to turn the string into a function, but the string includes references to this
. How do I preserve the right this
?
What's the best way of intercepting/overriding this bit of script? Note: this only needs to work in Firefox, not in any version of java/ECMAscript.
Thanks.