molily: Code dynamisch einem Eventhandler zuweisen

Beitrag lesen

Hallo,

meinobjekt.onclick = new Function(codestring);
Das quittiert mir der Firefox mit: "missing { before function body"

molily hat lediglich einen Parameter vergessen

Alle Parameter sind optional, ein Parameter ist dann der Funktionskörper:

»new Function(p1, p2, ... , pn, body)

The last argument specifies the body (executable code) of a function; any preceding arguments specify formal parameters.

When the Function constructor is called with some arguments p1, p2,..., pn, body (where n might be 0, that is, there are no "p" arguments, and where body might also not be provided), the following steps are taken: (...)«

(ECMAScript)

Mathias