Skip to content

Posting form data to wkwebview is not working #779

Open
@DS010

Description

@DS010

Bug Report

I am using inappbrowser plugin (v4.0.0) to redirect to external url, and trying to post data to the url through a form. It works fine in UIWebview, but when i upgraded to wkwebview it is failing.

let formContent = '<form action="' + URL + '" name=“myForm” id="myForm" method="post" target="secureiframe">';
    let element = document.createElement("div");
    let hiddenField = document.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", “username”);
    hiddenField.setAttribute("value", “test”);
    element.appendChild(hiddenField);
    formContent += element.innerHTML;
    formContent += "< /form>";
    let formContentUrl = 'data:text/html;base64,' + btoa(formContent);

let options = {location: 'no', usewkwebview: 'yes'}

var browser = this.inAppBrowser.create(formContentUrl, "_blank", options);

browser.on('loadstop').subscribe(event => {
       browser.executeScript({code:"document.getElementById('myForm').submit();"} );
 });

What is expected to happen?

Expected to post the form data to the url.

What does actually happen?

The form post data are ignored while redirecting.

Information

Environment, Platform, Device

IOS with Wkwebview

Version information

Cordova: Cordova CLI 9.0.0
Other Frameworks: Ionic 3.9.5 and CLI version 6.0.0
Operating System, Android Studio, Xcode etc.

Checklist

  • [ x] I searched for existing GitHub issues
  • [ x] I updated all Cordova tooling to most recent version
  • [ x] I included all the necessary information above

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions