iMr.WiFi..! Posted July 18, 2017 Share Posted July 18, 2017 (edited) Hey guys , i want make triggerEvent from client to html file and recepion from html file by java script <> how i can do it ? Edited July 18, 2017 by iMr.WiFi..! 1 Link to comment
pa3ck Posted July 18, 2017 Share Posted July 18, 2017 From Lua to Javascript, you use the executeBrowserJavascript which takes pure JS code. For example: executeBrowserJavascript(myBrowser, 'document.getElementById("myId").innerHTML = "hello";') //Or if you have jQuery executeBrowserJavascript(myBrowser, '$("#myId").html("hello");') 2 Link to comment
iMr.WiFi..! Posted July 18, 2017 Author Share Posted July 18, 2017 8 hours ago, pa3ck said: From Lua to Javascript, you use the executeBrowserJavascript which takes pure JS code. For example: executeBrowserJavascript(myBrowser, 'document.getElementById("myId").innerHTML = "hello";') //Or if you have jQuery executeBrowserJavascript(myBrowser, '$("#myId").html("hello");') oh thanks , but do you have any idea to let .html file accept php or <link /> ?? Link to comment
iMr.WiFi..! Posted July 19, 2017 Author Share Posted July 19, 2017 8 hours ago, iMr.WiFi..! said: oh thanks , but do you have any idea to let .html file accept php or <link /> ?? ^^^^ Link to comment
</Mr.Tn6eL> Posted July 19, 2017 Share Posted July 19, 2017 (edited) if you're use mta browsers yes you can try this example JS function onEvent(event) { if (event == "test") { console.log("Test event triggered!") mta.triggerEvent("myLuaEvent", "arg1", "arg2") // trigger lua event else if (event == "test2") { // more stuff } } Lua executeBrowserJavascript(browser, "onEvent('test')") addEvent "myLuaEvent" addEventHandler("myLuaEvent", browser, function(arg1, arg2, ...) print(arg1, arg2, ...) end) Don't forget to set development mode to web setDevelopmentMode(true, true) Then type /debugscript 3 1 hour ago, iMr.WiFi..! said: ^^^^ use html forms Edited July 19, 2017 by </Mr.Tn6eL> 1 Link to comment
iMr.WiFi..! Posted July 19, 2017 Author Share Posted July 19, 2017 14 minutes ago, </Mr.Tn6eL> said: if you're use mta browsers yes you can try this example JS function onEvent(event) { if (event == "test") { console.log("Test event triggered!") mta.triggerEvent("myLuaEvent", "arg1", "arg2") // trigger lua event else if (event == "test2") { // more stuff } } Lua executeBrowserJavascript(browser, "onEvent('test')") addEvent "myLuaEvent" addEventHandler("myLuaEvent", browser, function(arg1, arg2, ...) print(arg1, arg2, ...) end) Don't forget to set development mode to web setDevelopmentMode(true, true) Then type /debugscript 3 use html forms thank you so much .. 1 Link to comment
</Mr.Tn6eL> Posted July 19, 2017 Share Posted July 19, 2017 17 minutes ago, </Mr.Tn6eL> said: use html forms Or AJAX Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now