Reputation: 20534
We can instantiate a Inappbrowser using this in Apache Cordova :
var ref = window.open('http://apache.org', '_blank', 'location=yes');
Pretty straight forward :)
Now, i want to inject some scripts from the local storage in the page loaded in the InAppBrowser .
In cordova's InAppBrowser.java i found this method :
private void injectDeferredObject(String source, String jsWrapper)
But do not know how to call this from Cordova Api :(
Any help is greatly appreciated.
Upvotes: 2
Views: 1856
Reputation: 5376
It looks like this is a pretty new feature to allow the use of something like ref.executeScript(details,callback)
. It is actually documented here: https://github.com/apache/cordova-docs/blob/master/docs/en/edge/cordova/inappbrowser/inappbrowser.md#executescript but doesn't look like the doc website has been updated yet.
The current built version of the JavaScript doesn't seem to have this (just search for 'executeScript' and you'll see it is absent. It looks like you could try building your own copy of the JavaScript to test it out, since the bridge code already exists in the repo: https://github.com/apache/cordova-js/blob/master/lib/common/plugin/InAppBrowser.js#L55 and as you pointed out there is already Java code to support this (so, it should work at least on Android.) I'm not sure how well tested or supported this feature is yet though so you might run into some issues. You should try it out and let us know!
You can find instructions for building the JavaScript here: https://github.com/apache/cordova-js
Upvotes: 3