Subj : Re: Help regarding javascript execution To : netscape.public.mozilla.jseng From : Sterling Bates Date : Wed May 19 2004 11:34 am Shreekanth wrote: > Please post any pointers which would help solving this > problem. The "document" object, and the form object, are nothing more than simple properties of the global object. You can simulate this with typical javascript: document = new Object(); document.forms = new Array(); document.forms[0] = new Object(); document.forms[0].submit = new Function() {} This can be done from C as well: (forgive any errors, I'm not a C programmer) JSObject *global; JSObject *doc; JSObject *forms; JSObject *form; JSFunction *submit; global = JS_GetGlobalObject(cx); // document object doc = JS_DefineObject(cx, global, "document", nil, nil, 0); // array of forms forms = JS_NewArrayObject(cx, 0, nil); // make the forms a property of the document object JS_DefineProperty(cx, doc, "forms", OBJECT_TO_JSVAL(forms), nil, nil, 0); // create a form object form = JS_NewObject(cx, nil, nil, forms); // add the form to the list of forms JS_DefineElement(cx, forms, 0, OBJECT_TO_JSVAL(form), nil, nil, 0); // now create the submit function for the form submit = JS_NewFunction(cx, my_submit, 0, 0, form, "submit"); Then declare a function (of type JSNative) called my_submit, and it's called every time someone calls document.forms[0].submit(). You'll then have to take into account named forms, pages with more than one form, etc. I haven't done any error checking, and some of my code could be wrong, but hopefully you'll get the idea. Sterling .