import win.ui; /*DSG{{*/ mainForm = win.form(text="WebView2") mainForm.add( btnCallJs={cls="button";text="调用 JS 函数";left=461;top=395;right=726;bottom=449;note="点这里调用 JavaScript 函数";z=1}; custom={cls="custom";left=17;top=21;right=730;bottom=356;z=2} ) /*}}*/ //创建浏览器组件 import web.view; var wb = web.view(mainForm.custom); //导出本地函数给网页 JavaScript wb.external = { getComputerName = function(){ return sys.getComputerName(); } } import sys; //写入网页 HTML wb.html = /** **/ //响应按钮事件 mainForm.btnCallJs.oncommand = function(id,event){ //调用 JS 函数 wb.xcall("document.write","测试") } mainForm.show(); win.loopMessage();