Jump to content

LUA & JAVASCRIPT [ events ]


Recommended Posts

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");')

 

  • Like 2
Link to comment
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

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 :D

Edited by </Mr.Tn6eL>
  • Like 1
Link to comment
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 :D

thank you so much .. 

  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...