WebView code generating Uncaught TypeError and Uncaught ReferenceError errors on Android 4.4.2 (API 19) emulator

前端 未结 3 1769
误落风尘
误落风尘 2021-02-06 18:58

I\'m having a problem with my code when running on a Android 4.4.2 KitKat (API 19) emulator...

When I emulate my project on a Android 4.3 (API 18) emulator, it works nor

3条回答
  •  再見小時候
    2021-02-06 19:21

    I had the same problem when I moved different javascript functions out of the main page to an separate .js file. For some reason, Android can't find externally-loaded JavaScript webview functions from Java - only the ones in the main page. Once I moved the function back from the JS file, it immediately started working.

    Try making a "proxy" function like this directly inside the main HTML:

    function proxy() {
        call_some_other_function_from_JS_file();
    }
    

    This worked for me. I'm sure there must be a way to get find these functions, because I didn't have this problem on iOS. Someone please comment if you know a better way.

提交回复
热议问题