I compiled and run MfcEmbed
It works. Now I try to load a page which had some javascript, to call a
JSClass definides into my embedder.
Here is the code of the page
******************************************************************
Page qui lance un test
<script>
alert('test');
var c = new Customer();
c.name = "Franky";
c.age = 32;
alert(c.name);
var res = c.computeReduction();
alert(res);
</script>
********************************************************************
I build my embedder with the JSCustomer class and the customer class .
(JSCustomer and customer are the Spider'sMonkey sample).
I put this code into the BrowserView's onCreate function
******************************************************************************************************************
int CBrowserView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
CreateBrowser();
nsCOMPtr<nsIScriptGlobalObjectOwner>
theGlobalObjectOwner(do_GetInterface(mWebBrowser));
if (theGlobalObjectOwner) {
nsIScriptGlobalObject *theGlobalObject ;
theGlobalObjectOwner->GetScriptGlobalObject(&theGlobalObject);
nsIScriptContext *theScriptContext
=theGlobalObject->GetContext();
JSObject *theGlobalJSObject =
theGlobalObject->GetGlobalJSObject();
JSContext *theJSContext =
(JSContext*)theScriptContext->GetNativeContext();
JSObject *newObj = JS_InitClass(theJSContext,
theGlobalJSObject,NULL,
&JSCustomer::Customer_class, JSCustomer::JSConstructor, 0,
JSCustomer::Customer_properties,NULL, JSCustomer::Customer_properties,
NULL);
// JSObject *newObj = JS_InitClass(theJSContext,
theGlobalJSObject,NULL,&JSCustomer::Customer_class,
JSCustomer::JSConstructor, 0, NULL,NULL,
JSCustomer::Customer_properties, JSCustomer::Customer_methods);
JS_DefineObject(theJSContext, theGlobalJSObject,
"Customer",&JSCustomer::Customer_class, NULL, JSPROP_READONLY |
JSPROP_ENUMERATE |JSPROP_EXPORTED);
}
return 0;
}
******************************************************************************************************************
I start my mfcembed and load my page. Nothing appends.
Only the void JSCustomer::JSDestructor(JSContext *cx, JSObject *obj) is
called
What is wrong.
Is it possible to work with a class from javascript in such way???
If not , what do I do, and have you samples.
Thank's for your responses and help
philippe
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding