CodenameOne : Inject java script in downloaded web page

19 views
Skip to first unread message

crom_x

unread,
Jul 20, 2014, 5:01:31 PM7/20/14
to codenameone...@googlegroups.com
Hi,

Could anyone tell me if it is possible to inject java script in a downloaded web page?

I want than to load the final web page in the WebBrowser and do calls to the injected java script.

Thanks.

Shai Almog

unread,
Jul 21, 2014, 1:21:14 AM7/21/14
to codenameone...@googlegroups.com
Hi,
not to my knowledge although there might be tricks with iframe's etc. in the HTML side of the fence (not my forte).

You can intercept all navigation events and fetch the HTML on your own then use setPage to set the modified page. This is pretty tricky since resources might become an issue here.

Steve Hannah

unread,
Jul 21, 2014, 2:08:28 AM7/21/14
to codenameone...@googlegroups.com
Yes you can. Use BrowserComponent.execute() to embed a script tag in the page. E.g. using a strategy like this:

Once your javascript is loaded, you can start using it.

Steve


--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/fb380fbc-4424-4fcc-997a-d544417b4f5d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Steve Hannah
Web Lite Solutions Corp.
Reply all
Reply to author
Forward
0 new messages