Skip to content

Control of the WebView from an independent javascript instance. #303

@Qualphey

Description

@Qualphey

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions