마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

웹뷰에서 location.href가 전혀 먹지 않습니다.

0 추천
<script>
function webview_redirect(uri) {
    if(navigator.userAgent.match(/Android/i)){ 
        document.location=uri;
    }else if(navigator.userAgent.match(/iPhone|iPod/i)){
        window.location.replace(uri);
    }else if(navigator.userAgent.match(/iPad/i)){
        window.location.replace(uri);
    }else{
        window.location.href=uri;
    }
}
</script>

 

이렇게 document.location 해도 통하지 않네요.

다른 이유 때문인지...

막막하고 답답하네요.

alert도 안먹길래

 

@Override
public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result){
    new AlertDialog.Builder(myApp).setTitle("").setMessage(message).setPositiveButton(android.R.string.ok,
                    new AlertDialog.OnClickListener(){
                        public void onClick(DialogInterface dialog, int which){
                            result.confirm();
                        }
                    }).setCancelable(false).create().show();
    return true;
};
이렇게 해결했는데 location.href는 안되네요 ㅠ
국이짜구나 (220 포인트) 님이 2016년 8월 2일 질문
국이짜구나님이 2016년 8월 2일 수정

1개의 답변

+1 추천
 
채택된 답변
mWebView.getSettings().setJavaScriptEnabled(true); <-- 웹뷰에서 자바스크립타 사용가능하게 셋팅해주셨는지 먼저 체크하셔야할거같네요,
sadeva (21,550 포인트) 님이 2016년 8월 2일 답변
국이짜구나님이 2016년 8월 3일 채택됨
네 이미 세팅되어 있네요 ㅠㅠ       //javascript의 window.open 허용
        mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        //javascript 허용
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setSupportMultipleWindows(true); // 팝업허용
방금 샘플로만들어서해봤는데 잘되는데 .. 흠 혹시 해당 페이지 웹으로 들어가서 강제로 location 주면 작동되시나여?
아 메인에서 location 줘도 작동하지 않네요.
이미 다른곳에서 에러가 난것일까요?
혹시 웹뷰 에러를 볼수 있는 방법이 있을까요?
웹뷰쪽에서 에러나면 로그가 chroinum 인가 해서 나올거에요 그걸로 확인하심이..
감사합니다
폰갭쪽으로 해봐야할것 같습니다
document.location=uri;
window.location.href=uri;

여기 두개가 의심되는데요
...