apache / apache/cordova

Control of the WebView from an independent javascript instance.

Open
#303 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
710
Forks
75
PR merge metrics
No merged PRs in 30d

Description

# Feature Request

## Motivation Behind Feature

This feature would enable:
- Modifying html before loading it (i.e. rendering it with some templating engine).
- Smooth development using multi-page app architecture.

## Feature Description

An option to run Cordova apps with a "background" javascript instance that could control and communicate with the WebView.

## Alternatives or Workarounds

As an alternative you can use a single html file containing an iframe and scripts. Instead of loading desired pages in WebView the app would read the html file, render it adding mutation observers, write contents to a different file and then load that file in an iframe.

Drawbacks of the workaround:
- Apps become harder to debug.
- Unnecessary file reads/writes.
- Mutation observers have to be rendered into html in order to override link behavior. So that the iframe would send a message back to WebView making it read the next html file, render, write and load it in the iframe.
- On android platform `applicationDirectory` is read only, so you have to write the rendered html file to a different directory. In this case you have to either: copy all resources that are loaded using relative paths into the same directory or modify relative path when rendering html.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.