[Project_owners] Re: help needed with javascript function eval

Neil neil at parkwaycc.co.uk
Thu May 5 12:48:29 EDT 2005


Michael Vincent van Rantwijk wrote:

> Hi,
> Someone reported this bug report:
>
> http://bugzilla.mozdev.org/show_bug.cgi?id=10119
>
> after noticing the following JS error on his JS console:
>
> Error: [JavaScript Error: "function eval must be called directly, and 
> not by way of a function of another name"
>
> for this line: aWindow.eval('Window.prototype.open = 
> '+this.mzWindowOpen.toSource());
>
> But the problem is that I don't know how to solve this, I'm not a 
> javascript expert so can any of you 'old timers' (in respect of 
> writing/using javascript) please advice me?

I know two workarounds:
aWindow.setTimeout('Window.prototype.open = ' + 
this.mzWindowOpen.toSource(), 0);
(obviously that happens after your script finishes)
Components.classes['@mozilla.org/moz/jssubscript-loader;1']
          .createInstance(Components.interfaces.mozJSSubScriptLoader)
          
.loadSubScript('data:application/x-javascript,Window.prototype.open = ' +
                         this.mzWindowOpen.toSource(), aWindow);
(note: I may have misremembered the code)


More information about the Project_owners mailing list