Shared Script Sample: More Dragons!
Item logo image for Shared Script Sample: More Dragons!

Shared Script Sample: More Dragons!

Developer Tools15 users
Item media 1 screenshot

Overview

Accessing the main world with <webview>.executeScript() Web view content scripts run in an isolated world. This means that they can…

Accessing the main world with <webview>.executeScript() Web view content scripts run in an isolated world. This means that they can access the current page's DOM, but cannot share objects with scripts included in the DOM because scripts in the DOM run in the main world. For a more detailed explanation, checkout [this video](https://www.youtube.com/watch?v=laLudeUmXHM). Running in an isolated world is usually what the developer wants because access to the DOM is enough. Sometimes, the developer may want to access Javascript objects in the main world. This sample shows good and bad examples of injecting Javascript into a <webview> that is intended to run in the main world. To do this correctly, content script must create a <script> tag and inject it into the DOM. Then, the script contained within the <script> tag will be run in the main world. The sample shows a page that contains an animated dragon. The injected script adds the ability to construct dragons that animate in sync. In order to do so, the script needs access to the Dragon FOAM model. To gain access, the injected script inserts a <script> tag into the DOM. The sample contains two app windows: Incorrect injection attempts to inject the script directly and Correct injection injects the script into a <script> tag in the DOM. See the source code at https://github.com/GoogleChrome/chrome-app-samples/tree/master/webview-samples/shared-script This version was built from git commit ebc7784 https://github.com/GoogleChrome/chrome-app-samples/tree/ebc7784/webview-samples/shared-script

0 out of 5No ratings

Google doesn't verify reviews. Learn more about results and reviews.

Details

  • Version
    2.0
  • Updated
    September 2, 2014
  • Offered by
    Chrome App Samples
  • Size
    134KiB
  • Languages
    English (United States)
  • Non-trader
    This developer has not identified itself as a trader. For consumers in the European Union, please note that consumer rights do not apply to contracts between you and this developer.

Privacy

The developer has not provided any information about the collection or usage of your data.

Support

For help with questions, suggestions, or problems, visit the developer's support site

Google apps