Obsolete since JSAPI 27
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Enables and disables options on a JSContext
, replacing all previously set options.
Syntax
uint32 JS_SetOptions(JSContext *cx, uint32 options);
Name | Type | Description |
---|---|---|
cx |
JSContext * |
A context on which to set options. |
options |
uint32 |
The new set of options. This is the logical OR of zero or more flags described below. |
Description
JS_SetOptions
sets the option flags of a given JS context cx
. This function returns a uint32 value containing the previous values of the flags.
To turn individual options on or off, use JS_SetOptions
with JS_GetOptions
:
// turn on warnings for dubious practices JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_EXTRA_WARNINGS); // turn off those extra warnings JS_SetOptions(cx, JS_GetOptions(cx) & ~JSOPTION_EXTRA_WARNINGS);
The options
parameter and the return value are the logical OR of zero or more constants from the following table:
Option | Description |
---|---|
|
Warn on dubious practice. |
|
Convert warnings to errors. |
|
Make This flag is recommended. Without it, the two scripts " |
|
Mozilla extension. The context's private data points to an XPCOM object (see |
|
Caller of |
|
|
|
Obsolete since JSAPI 15 ECMAScript for XML (E4X) support: parse |
JSOPTION_ALLOW_XML |
Added in SpiderMonkey 15 If this is off, E4X syntax isn't supported no matter what version number is set. |
JSOPTION_MOAR_XML |
Added in SpiderMonkey 15 ECMAScript for XML (E4X) support: parse JSOPTION_MOAR_XML |
|
The branch callback set by |
|
When returning from the outermost API call, prevent uncaught exceptions from being converted to error reports. |
|
Added in SpiderMonkey 1.8 Throw an exception if a regular expression backtracks more than n3 times, where n is the length of the input string. |
JSOPTION_ANONFUNFIX |
Added in SpiderMonkey 1.8 Disallow |
JSOPTION_JIT |
Obsolete since JSAPI 11 Added in SpiderMonkey 1.8.1 Enables the JIT compilation of code in the context. Note that you may currently (Jan 2009) experience bugs with this option enabled. |
JSOPTION_NO_SCRIPT_RVAL |
Added in SpiderMonkey 1.8.1 By setting this option, the application promises to the compiler that a null rval out-param will be passed to each call to |
JSOPTION_UNROOTED_GLOBAL |
Added in SpiderMonkey 1.8.1 Instructs the garbage collector not to consider the context's global object a root. The application must ensure that the global object survives as long as the |