| function testxpcom(f) { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var ret_string; ret_string = mycom.Hello(document.form_test.input_string.value); alert(ret_string); } </script> <form name="form_test"> 输入信息: <textarea name = "input_string" cols = "70" rows = "5"></textarea> <input type="button" value="testxpcom" onClick = "testxpcom(this.form);"> </form> </body> </html> //-------------------------------------------------- 我们在mozilla中打开该html,在输入框中输入一些文字,在点击testxpcom后,怎么样,看到从组件返回的信息了吗? 另外,上面的输入信息如果是中文,则返回中会产生乱码,xpcom idl中有nsAString, wstring等支持unicode的字符串类型,由于在参数的传递中会涉及一些转换,因而未提及。 以上只是展示了XPCOM组件的基本技术,还有许多内容未提及,如果要将该技术应用于项目中,更多的资料请查阅mozilla的网上资源。
上一页 [1] [2] [3] [4] |