draobrehtom Posted December 25, 2015 Share Posted December 25, 2015 The Main Question: How I can send data to HTML page (CEF browser) from Lua code? I know has executeBrowserJavascript, but I don't know how exactly I can use it, I try define variables like a executeBrowserJavascript(theBrowser, "var example = 5") And use it in HTML code mta.triggerEvent("cmsg", example) but nothing. Or: var test = mta.triggerEvent("cmsg", "hello mta") mta.triggerEvent("cmsg", test) And: function cmsg(msg) outputChatBox(tostring(msg)) return 5 end addEvent("cmsg", true) addEventHandler("cmsg", root, cmsg) But variable test is "unsupported type" (showing outputChatBox) Can you help me? Link to comment
draobrehtom Posted December 25, 2015 Author Share Posted December 25, 2015 I found a one way with using Using innerHTML. Here is my code: Lua: function cmsg(msg) executeBrowserJavascript(theBrowser, 'document.getElementById("demo").innerHTML = "' .. msg .. '"') end addEvent("cmsg", true) addEventHandler("cmsg", root, cmsg) HTML: <!DOCTYPE html> <html> <body> <p id="demo"></p> <script> mta.triggerEvent("cmsg", "Hello MTA") </script> </body> </html> Link to comment
draobrehtom Posted December 27, 2015 Author Share Posted December 27, 2015 Finally I did Login Panel based on HTML. Thanks for watching. Link to comment
HACXK Posted April 27, 2024 Share Posted April 27, 2024 hey! can you send how can parse data between lua and html Link to comment
Prox69 Posted April 27, 2024 Share Posted April 27, 2024 5 hours ago, HACXK said: hey! can you send how can parse data between lua and html https://wiki.multitheftauto.com/wiki/CEF_Tutorial#Lua_<==>_Javascript_communication 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