Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/439.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在android中获取从IFRAME WEBVIEW发送的信息_Javascript_Android_Webview - Fatal编程技术网

Javascript 在android中获取从IFRAME WEBVIEW发送的信息

Javascript 在android中获取从IFRAME WEBVIEW发送的信息,javascript,android,webview,Javascript,Android,Webview,在Iframe中,我有如下功能的postMessage window.parent.postMessage( { id: 'Show', data: { live: 10 } }, "*" );

在Iframe中,我有如下功能的postMessage

               window.parent.postMessage(
                {
                    id: 'Show',
                    data: {
                        live: 10
                    }
                }, "*"
            );
现在我将此框架加载到webview android

private WebView wv;
String html = "<iframe class=\"youtube-player\" style=\"border: 0; width: 100%; height: 95%; 
       padding:0px; margin:0px\" id=\"ytplayer\" type=\"text/html\" src=\"https://example.com" + "?
       fs=0\" frameborder=\"0\">\n" + "</iframe>";
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        wv = (WebView)findViewById(R.id.webView);
        wv.getSettings().setJavaScriptEnabled(true);        
        wv.loadDataWithBaseURL("", html , "text/html",  "UTF-8", "");

    }
private-WebView-wv;
字符串html=“\n”+”;
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wv=(WebView)findviewbyd(R.id.WebView);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadDataWithBaseURL(“,html,“text/html”,“UTF-8”,”);
}
现在我想从postMessage函数的id:'Show'中捕获数据

我搜索了stackoverflow和google,但找不到任何有用的信息

我曾尝试使用“addJavascriptInterface”,但它不起作用。

你能给我看一下从JS获取消息的代码吗? 谢谢