Bug in Opera? Problems calling Prototype’s evalScripts()
March 16th, 2006
Prototype is a great JS library for building your AJAX enabled web pages and I am using it in a project I am working on. However when I was testing my application inside Opera 8.53 one of my little interactive widgets stopped working. The problem was due to the widget downloaded a little piece of extra scripting capability which needed to be added to the page, so evalScripts was being called from the AJAX responder. But this was doing nothing inside Opera.
Don’t ask me what the problem is, but I have got round it, here is the quick fix in case anybody else needs it.
Replace the single line inside your prototype evalScripts with this one:
return this.extractScripts().map(fixedEval);
and outside of the string object extend block add
function fixedEval(a) {
return eval(a);
}
I’ve got no idea why this should fix it, but it does. Basically I just added that code with an alert() instead of the eval() to see that the scripts where being passed through. Curiosity made me put the eval() in there, after that test seemed fine. This fix works fine with MSIE and Firefox too.




This problem is going to be fixed in Prototype 1.5 it seems. Their solution is basicaly the same except they use an inline function. Forgot you could do that… doh!
Comment by Ian — April 11, 2006 @ 1:15 pm