zephyrer / executejs

Automatically exported from code.google.com/p/executejs
0 stars 0 forks source link

EvalError when Content Window is ticked on #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Tick on checkbox "Content window"
2. All execution of JS code result in an EvalError: function must be called
directly
3.

What is the expected output? What do you see instead?

Please use labels and text to provide additional information.

Original issue reported on code.google.com by Rudolf....@gmail.com on 2 Nov 2008 at 6:55

GoogleCodeExporter commented 9 years ago
This can be fixed
edit executeJS.js ("firefox profile 
folder\extensions\{7067a92c-1db4-4e5e-869c-25f841287f8b}\chrome\content\executej
s\executeJS.js")
function EJS_evalStringOnTarget

replace
return EJS_currentTargetWin.eval(evalString);
with
return eval(evalString,EJS_currentTargetWin);

this is because there are more than one javascript implementation
eval(code, obj) // old style

with(obj) {
    eval(code) // modern style
}

Unfortunately, modern style is not supported by all the firefox objects yet. 
Good old plain eval works better sometimes.

Original comment by Ilya.Kharlamov on 22 Sep 2010 at 3:51