语法: |
ui.callJs(name,js) |
|
参数 |
类型 |
说明 |
name |
字符串类型 |
控件名称,id |
js |
字符串类型 |
js回调函数字符串 |
return |
布尔类型 |
true 调用成功 false 调用失败 |
注意事项 |
当前窗口中加载一个浏览器界面,浏览器界面必须存在,你可以理解为加载H5ui界面 |
local html = "PGh0bWw+DQo8aGVhZD4NCiAgICA8dGl0bGU+5rWL6K+VbHVh5ZKManPnm7jkupLosIPnlKg8L3RpdGxlPg0KICAgIDxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0idGV4dC9odG1sO2NoYXJzZXQ9VVRGLTgiPg0KICAgIDxtZXRhIGlkPSJ2aWV3cG9ydCIgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCxpbml0aWFsLXNjYWxlPTEuMCxtaW5pbXVtLXNjYWxlPTEuMCxtYXhpbXVtLXNjYWxlPTEuMCxtaW5pbWFsLXVpIj4NCiAgICA8c2NyaXB0IHR5cGU9InRleHQvamF2YXNjcmlwdCI+DQogICAgICAgIGZ1bmN0aW9uIGNhbGxqcyhhcmcpew0KICAgICAgICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJjb250ZW50IikuaW5uZXJIVE1MICs9DQogICAgICAgICAgICAgICAgICI8YnJcPmx1Yeiwg+eUqOS6hmpzPT4iK2FyZzsNCiAgICAgICAgfQ0KDQoJCWZ1bmN0aW9uIGNhbGxMdWEoKSB7DQoJCQl3aW5kb3cuYnJpZGdlLmNhbGxMdWEoIm9uSnNDYWxsQmFjayhcInRlc3RcIikiKTsNCgkJfQ0KICAgIDwvc2NyaXB0Pg0KPC9oZWFkPg0KPGJvZHk+DQogICAgPGJyLz48YnIvPg0KICAgIDxsaT48YSBvbkNsaWNrPSJjYWxsTHVhKCkiPueCueWHu+iwg+eUqGx1YeS7o+eggTwvYT48L2xpPg0KCTxkaXYgaWQ9ImNvbnRlbnQiPjwvZGl2Pg0KPC9ib2R5Pg0KPC9odG1sPg0K"
local text = decodeBase64(html)
print(text)
writeFile("/sdcard/test.html",text)
function onJsCallBack(arg)
local ret = ui.callJs("webId","javascript:calljs(\"hello\")")
print("onJsCallBack:",arg,ret)
end
ui.newLayout("layout1")
ui.addWebView("layout1","webId","file:///sdcard/test.html",-1,500)
ui.show("layout1")
sleep(100000)