admin管理员组文章数量:1279017
I'm trying to create a Android WebView app. When I press a button in the webview with the following code behind it:
window.location.href = "";
Nothing happens, but in the chrome browser on Android it will work. I can also confirm that javascript is enabled because I can change the backgrond color by using javascript in the webview.
I'm trying to create a Android WebView app. When I press a button in the webview with the following code behind it:
window.location.href = "https://www.example.nl";
Nothing happens, but in the chrome browser on Android it will work. I can also confirm that javascript is enabled because I can change the backgrond color by using javascript in the webview.
Share Improve this question asked May 8, 2017 at 12:49 UNTITLED.PNGUNTITLED.PNG 5312 gold badges6 silver badges13 bronze badges3 Answers
Reset to default 3use this instead:
window.open("https://www.example.nl", "_self")
Override the WebView shouldOverrideUrlLoading, like this:
myWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
Did you try document.location
without the href
property ?
本文标签: javaANDROID WebView javascript redirect won39t workStack Overflow
版权声明:本文标题:java - ANDROID WebView javascript redirect won't work - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741302145a2371150.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论