0

当我尝试从使用 PhoneGap 的 android 应用程序调用 javascript 调用时,出现以下异常。

堆栈跟踪错误:

06-01 13:58:40.225: D/CordovaLog(1197): Uncaught ReferenceError: recieve is not defined
06-01 13:58:40.225: E/Web Console(1197): Uncaught ReferenceError: recieve is not defined at null:1

这是我的 .jp 文件

    <!-- register -->

        function register(toggle){
        var e = toggle;
        var value = e.options[e.selectedIndex].value;
        console.info(toggle);
        console.info(value);
            if (value == "on"){
                window.WRAPPER.register();
            }else if(value == "off"){
                window.WRAPPER.deregister();
            }

        }


  <!-- send  -->

        function send(message){
            console.info('sending message');
            console.info(message);
            window.WRAPPER.send(message);
        }


    <!-- recieve -->

        function recieve(msg){
            console.info('recieving message');
            console.info(msg);
            document.getElementById("textarea1").innerHTML = msg;
        }

这是我的 android 代码,它创建一个 javascript:functionName() 字符串并将其加载到 webView

String text = "hello";

String javaScript = "javascript:recieve(\'"+text+"\')";

Log.d("TAG", javaScript);

loadUrl(javaScript);
4

0 回答 0