Reputation: 1742
I just started playing around with Windows Dev and please pardon me if this issue does not seem logical or legit to you.
I am trying these Chakra Host samples on Microsoft GitHub and when input js cond like console.log
or alert
, I get error like 'console' is undefined
. Am I missing something obvious. I tried looking up but unfortunately could not find the relevant docs or code sample.
Any help/pointer is appreciated.
Upvotes: 3
Views: 812
Reputation: 59763
The console
is a web browser (and Node) feature. It doesn't exist within JavaScript. So, you need to add it (or something similar).
There's an example in the Win32 Edge/Chakra host code on Github that demonstrates how to add a callback function to the global namespace.
You should be able to do something similar. You can also expose existing Windows runtime namespaces to Chakra.
private static void DefineHostCallback(JavaScriptValue globalObject, string callbackName, JavaScriptNativeFunction callback, IntPtr callbackData)
{
var propertyId = JavaScriptPropertyId.FromString(callbackName);
// Create a function
var function = JavaScriptValue.CreateFunction(callback, callbackData);
// Set the property
globalObject.SetProperty(propertyId, function, true);
}
Upvotes: 2