This concept has been introduced also into this plugin with the
Content worlds help prevent issues that occur when two scripts modify environment variables in conflicting ways.
You might use this support in the following scenarios:
- You have complex script logic to bridge your web content to your app, but your web content has complex script libraries of its own. In that scenario, use one content world for your app-specific scripts and a separate content world for your content-specific scripts.
ContentWorld object is a namespace and doesn’t persist data outside of the current WebView or web page. If you use the same content world in two WebView objects, variables in one WebView’s content world don’t appear in the other WebView. Similarly, when the user or your app navigates to a new web page, variables from the previous page are gone, even if both pages share the same content world.
ContentWorld provides a default content world for your app (
ContentWorld.DEFAULT_CLIENT) and a content world for the current web page (
ContentWorld.PAGE). You can also create new content worlds using
Unfortunately, on Android, this concept doesn’t exist natively. So, it has been implemented with the usage of
<iframe> HTML elements.
The problem with using these libraries/framework is that you can’t access the
ContentWorld, you can access these objects and, so, you can interact with the web page itself.
<iframe> tag with the
id attribute equals to
Obviously, this comes with some limitations/disadvantages:
- for any
ContentWorld.PAGE(that is the web page itself), if you need to access the
documentglobal Object, you need to use
window.top.documentrespectively because the code runs inside an iframe;
- the execution of the inline
scripts could be blocked by the
Here is a simple usage example: