Kamycz3q Posted February 28, 2020 Share Posted February 28, 2020 How i can make onclick event trigger in js? HTML <button id="zakup_glock18" class="zakup_glock18" onload='mtatools._callEvent("onChat", "[1, {\"firstName\":\"John\"}]" );'>Zakup</button> JS: var eventHandlers = []; var MTAUtils = function() {}; MTAUtils.prototype.registerEvent = function(eventName, handler) { eventHandlers[eventName] = handler; } MTAUtils.prototype._callEvent = function(eventName, jsonArgs) { var func = eventHandlers[eventName]; if (!func) return false; func.apply(null, JSON.parse(jsonArgs)[0]); } mtatools = new MTAUtils(); mtatools._callEvent("onChat", "[1, {\"firstName\":\"John\"}]" );*/ Link to comment
Administrators Tut Posted February 29, 2020 Administrators Share Posted February 29, 2020 Hello and welcome to the forums @Kamycz3q! Please use the Scripting section in the future when making threads asking for help related to MTA coding. We have moved a few of your threads to the appropriate section, please keep that in mind for future questions you may ask in the forum. There are also some stickied threads in (most) sections which contain guidelines for posting in their section. https://forum.multitheftauto.com/forum/71-scripting/ 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