ExecuteJavaScript from a JS file

Having problems with building or using the JCEF Java binding? Ask your questions here.

ExecuteJavaScript from a JS file

Postby TuanODB » Fri Mar 03, 2017 4:48 am

Hi guys,
I'm fresher in Java-CEF. I have built a simple project and I want to ask how can I execute Javascript from a .js file in my Project folder instead write these script into executeJavascript method of CefBrowser.
Thanks guys.
TuanODB
Newbie
 
Posts: 4
Joined: Fri Mar 03, 2017 4:44 am

Re: ExecuteJavaScript from a JS file

Postby Czarek » Sat Mar 04, 2017 2:35 am

You have to load content from the .js file and pass it to executeJavascript. There ain't other methods.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: ExecuteJavaScript from a JS file

Postby TuanODB » Sat Mar 04, 2017 6:53 am

Thank you man,
In syntax of ExeJS method: ExecuteJavaScript(<script>,<url>, 0);
Is there anyway to put my .JS file path to <url>???
Have a nice day!!!
TuanODB
Newbie
 
Posts: 4
Joined: Fri Mar 03, 2017 4:44 am

Re: ExecuteJavaScript from a JS file

Postby Czarek » Sat Mar 04, 2017 10:28 am

I believe you can put any string to <url> param, it doesn't have to be a real path, it is just for display purposes in case of Exception occurs in javascript, so you can know from where the javascript code originated from. Have a nice day too.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 18 guests