Instance of IActiveScript, that implements the IE9's JavaScript engine (“Chakra”), works in a Quirks mode

1.5k Views Asked by At

By creating an instance of IActiveScript on the basis of CLSID "{16d51579-a30b-4c8b-a276-0ff4dc41e755}" (as described here), we get IE9's JavaScript engine, which works in a Quirks mode. Unfortunately, in the Quirks mode is not supported ECMAScript 5.

Does anyone know how to create an instance of the IActiveScript for the “Chakra”, that works in the IE9 standards mode?

3

There are 3 best solutions below

1
On BEST ANSWER

Cast your IActiveScript to IActiveScriptProperty then call SetProperty with SCRIPTPROP_INVOKEVERSIONING on it like that:

CComQIPtr<IActiveScriptProperty> property = jscript;
CComVariant version(SCRIPTLANGUAGEVERSION_5_8 + 1); // = 3
hr = property->SetProperty(SCRIPTPROP_INVOKEVERSIONING, nullptr, &version);
0
On

I believe the CLSID is 16d51579-a30b-4c8b-a276-0ff4dc41e755. There's all sorts of great information on the Active Script and JScript interfaces here, especially for those working with C#.

0
On

Just in case people wonder: The trick of calling “SetProperty” with “SCRIPTPROP_INVOKEVERSIONING” still works. The greatest supported version is now (with jscript9.dll version 11.0.16299.2107) apparently 15.

It seems to support whatever “recent” feature is available in IE, such as “let”, “const” or “Map”, but no what is supported in Edge (such as “class”).