0

I'm trying to automatically redirect from a local html file in an android web-view to a browser window when a cookie is read. The JavaScript below opens the URL in the web-view but I need it to open in a separate browser instead.

onload=function(){
    document.getElementById('linksNewWindow').checked = readCookie('linksNewWindow')==1? true : false;
    if(document.getElementById('linksNewWindow').checked = readCookie('linksNewWindow')== true){
        location.href = "url";
    }
}

The code for the android app just calls the local html file into the webview

if (android.os.Build.VERSION.RELEASE.startsWith("4.4.2")) {

    String localUrl = "file:///android_asset/splash/splashKitkat.html";
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(localUrl);          
} 

I'm not sure if this is a small issue with my javascript or something bigger if someone could help me out that would be great. Thanks in advance

Makoto
  • 765
  • 2
  • 17
  • 45
user1984755
  • 25
  • 1
  • 4

1 Answers1

0

You can use Javasctipt-Java bridge and call Android code from your custom HTML javascript inside WebView. That Android code may launch intent for the external browser. See more Call Java function from JavaScript over Android WebView

Community
  • 1
  • 1
Eugene Popovich
  • 3,343
  • 2
  • 30
  • 33