Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.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
Android将webview中的javascript变量转换为java变量_Java_Javascript_Android_Webview - Fatal编程技术网

Android将webview中的javascript变量转换为java变量

Android将webview中的javascript变量转换为java变量,java,javascript,android,webview,Java,Javascript,Android,Webview,阶级 onCreate() 我想用java获取“elementjs” WebView webview = (WebView) findViewById(R.id.webView1); webview.getSettings().setJavaScriptEnabled(true); webview.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT"); webview.loadUrl("javascript:var

阶级

onCreate()

我想用java获取“elementjs”

WebView webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");    
webview.loadUrl("javascript:var elementjs = window.HTMLOUT.processHTML(document.getElementsByName('name')[0].src);");
如何在java中获取javascript变量

WebView webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");    
webview.loadUrl("javascript:var elementjs = window.HTMLOUT.processHTML(document.getElementsByName('name')[0].src);");
String element = elementjs;//like this