Skip to content

Does "bridge.callHandler()" makes submitForm() failure? #169

@bingbingBang

Description

@bingbingBang

My english is poor but I hope you can understand :)

There is a web page in my app and I added some example javascript API by using 'WKUserScript' in WKWebView, this web page has a button like this :
"<button onclick="return submitForm()" name="save" class=...."

I add a event listener in connectWebViewJavascriptBridge() :

connectWebViewJavascriptBridge(function(bridge) {

 bridge.init(function(message, responseCallback) {
            responseCallback("Right back atcha")
           })

var elements = document.getElementsByName("save")
var saveBtn = elements[0]
saveBtn.addEventListener("click", function() {
                        bridge.callHandler('settingPageCallBack', {'foo': 'bar'})
                        }, false)
})

When I run my app use these javascript code the web page will get stuck when I click save button, but if I delete 'bridge.callHandler('settingPageCallBack', {'foo': 'bar'})' the save button will submit success, I don't know how to fix this, any advice?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions