<script src="lua.vm.js"></script>
<script type="text/lua">
function YourLuaFunction()
-- your Lua code is here
end
</script>
<button id="MyBtn">Lua inside</button>
<script type="text/lua">
js.global.document:getElementById("MyBtn"):addEventListener("click", YourLuaFunction);
</script>
<script src="lua.vm.js"></script>
<script>
function executeLua(code) {
try { L.execute(code); } catch(e) { alert(e.toString()); }
}
</script>
<script type="text/lua">
function YourLuaFunction()
-- your Lua code is here
end
</script>
<button onclick="executeLua('YourLuaFunction()')">Exec Lua code</button>
参看