Web Browser Click

Hi, guys. Is there a way to get a click or event from a small html/javascript page using the web browser and execute a script in vision? I can't find a way :sleepy:

It would be a major security hazard if browsers could execute programs on a client OS. Browsers don't allow that.

Why don't you describe the real problem you're trying to solve rather than your solution?

I'm using the web browser component to draw a map with openstreetmap, and I want to run a script when I click on a marker. I know there is no problem doing it in perspective, but I need it from vision.

I appreciate the help.

You're wanting to execute javascript in the web browser component?
It can be done in this way:

webComponent = event.source #or whatever your relative path is
webbrowser = webComponent.browser
frame = webbrowser.focusedFrame()
if frame.isPresent():
	frame.get().executeJavaScript("PUT YOUR JAVASCIPT AS A STRING HERE")

Hi!

I am trying to capture an event from the web browser to do something via script from vision later.

We know. You've told us twice already.

1 Like

The way in which you listen to a click is by injecting custom JavaScript. You'll have to research how to create the appropriate listener and where to inject it on your own. Jxbrowser sets up certain hooks that would allow the page to send a message back to the constaining Java application; you're also going to have to look up how to do that.

Just about everything you would need to figure this out can be found in the guides and tutorials sections of the jxBrowser documentation:

Thanks, I'll check it out.