I have loaded a url in webview, when I click on a button a new view appears in the webview without changing the url. Is there any way to capture this state change in the webview?
yeah checkout https://developer.android.com/reference/android/webkit/WebView#addJavascriptInterface(java.lang.Object,%20java.lang.String) using js interface is the only way to register changes in the webview
Related
I implement webview in recyclerview item and Webview result does not set properly.
Click here for image
I think you are trying to build the tab minimising functionality similar to chrome/firefox, instead of using webview inside the minimised items, you can map every page to an image and store it internal storage, also, you don't want the user to interact with pages in minimised state, so webview is not required.
In android app I have webView page that use jquery plugin for lazyload. In mobile browser it work fine but not in webView. After debug I find out that even this doesnt trigger alert.
$(window).scroll(function() {
alert("Scrolled");
}
Does there is special way to handle scroll events in webView?
PS For lazy load i use this plugin http://www.appelsiini.net/projects/lazyload
window.onscroll works with the WebView. Some things to check:
you have placed the WebView in a ScollView and/or set it's height to wrap_contents,
the contents of the WebView is too short to scroll,
you haven't implemented the WebChromeClient.onJsAlert callback to handle alert. By default the WebView doesn't display a popup.
I have an invisible listener above of webview and i want that when the user click on this area, the invisible listener does something and if the web has some button, it does like if the invisible listener doesn't exist.
Look into the use of Javascript interfaces within WebView. Please see this area of the Android Developers Guide. Basically, you should be able to communicate from the page to the device with the Javascript interface and let your WebView Activity know whether the button on the page is present or not.
So I have a html app that I'm loading in a WebView. The thing is I want to use shouldOverrideUrlLoading not to load a specific link, when it gets clicked, so I return true in that method, not loading the url. This works great, but the link is getting highlighted as if it was clicked. Is there a way that I can remove the highlighting if the link was pressed but not loaded?
Thanks
You could have one of a few problems, Clicking on the link in android webview does not get highlighted visually says you have to set Javascript as enabled with:
webView.getSettings().setJavascriptEnabled(true);
There's also been an issue with focus at Android:Webview with link highlight, where you should request focus on your webview with:
webView.requestFocus(View.FOCUS_DOWN);
Hi I would like to know if there is a way to make the Android Webview cache changes made to the DOM of the loaded page so that when I go back to it, the previously loaded changes remain.
An example would be I'm on page A, call javascript that adds more html content (from an ajax call or w/e), and then I go to Page B. When I hit the back button to go back to page A, page A only displays what the original page load displays.
Is there any quick way around this?
Try this
WebView view = new WebView(this);
view.getSettings().setJavaScriptEnabled(true);
view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
view.clearCache(false);