Skip to content

How do I pass messages back from the html page to native ? #168

@manujbahl

Description

@manujbahl

I tried a couple things.

  1. doing a window.open
  2. hooking into the script message mechanism by using a userContentController and WKScriptMessageHandler

nothing seems to work.

even an alert does not fire.
Here is my webview plugin

var str = "<html><body><h1>Add text below</h1><input type='text' name='email' id='email'/><button onclick='window.open(\"http:\\www.cnn.com\"); '>Click me</button></body></html>";
        var url = new Uri.dataFromString(str, mimeType: 'text/html').toString();
        
        flutterWebviewPlugin.launch(url,
                  rect: new Rect.fromLTWH(
                      00.0, 100.0, 300.0, 440.0));
 

the navigation to cnn.com does not happen on button click.
I also tried to just do an alert but did not work.

var str = "<html><body><h1>Add text below</h1><input type='text' name='email' id='email'/><button onclick='alert(\"test message\"); '>Click me</button></body></html>";

what seems to be the issue? any ideas?

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