Jump to content

Problem with CEF and executeBrowserJavascript


xDog

Recommended Posts

HI Community,

I am quite new to using CEF and therefore I have a problem with the function executeBrowserJavascript.

Heres my code from LUA

function JSHandler:execute(event,arg)
	if self.browser then 
		local jsString
		if type(arg) == "table" then 
			jsString = toJSON(arg)
		elseif type(arg) == "number" or type(arg) == "string" then 
			jsString = tostring(arg);
		end 
		local query = self.browser:executeJavascript(("App.callEvent('%s','%s')"):format(event,jsString));
		if query then 
			return true 
		else 
			self:debug("Please check your script. There must be some missing part!")
		end 
	end 
end  

and my JS Code

ApplicationHandler.prototype.registerEvent = function(eventName,handler){
	eventHandlers[eventName] = handler;
	return true;	
}
ApplicationHandler.prototype.callEvent = function(eventName,args){
	if(eventHandlers[eventName]){
		eventHandlers[eventName].apply(null, args);
	}
}

ApplicationHandler.prototype.__click = function(){}

App = new ApplicationHandler();

//Event
App.registerEvent("getPlayers",function(arg){Playerlist.getPlayers(arg);});

and it shows me the following error: [Browser]:Console: UncaughtReferenceError: App is not defined().

 

Maybe you could help me with this problem, thx in advance!

 

 

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...