Tuesday, May 13, 2014
How to Read Javascript Variables From WebView on the Android
1. Open the Eclipse Java software and the Android app you want to edit. Double-click the Java source code file that contains the WebView control.
2. Load the WebView URL. The following code opens a website page in the Android's viewer:webView.loadUrl('site.com');Replace 'site.com' with the URL that contains the JavaScript variables.
3. Load the JavaScript Web settings. JavaScript is disabled by default, so you must enable JavaScript to view the variables. Add the following code to your function:WebSettings setup = webView.getSettings();
setup.setJavaScriptEnabled(true);
4. Retrieve the JavaScript variable you want to view. You must call the JavaScript function contained in the Web page to view the variables. Add the following code to retrieve the variables and the variables' values:webView.loadUrl('javascript:myfunction()');Replace 'myfunction' with the name of your JavaScript function.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment