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

webview에서 연속 redirect 문제

0 추천
webview를 통해 오픈된 페이지가 연속으로 5번정도 리다이랙션을 하는데,.

3번쯤 하면 멈춰있는 현상이 있네요~...

왜 그런지 전혀 감이 잡히지 않습니다... 혹시 선 경험이 있으신 분 댓글좀 부탁드려요..

제가 생각하는 문제는...

1. html5 또는 자바스크립트 리다이랙션 처리오류?

2. 리다이랙션 호출 URL디코딩 문제...

3. 보안상 리다이랙션 오류

수고하세요~
당그니2 (200 포인트) 님이 2013년 11월 25일 질문

2개의 답변

0 추천
shouldoverrideurlloading 에서 중간에 가로채서

post 를 이용해 딜레이 처리해보시는게 어떠신지요?
익명사용자 님이 2013년 11월 25일 답변
답변감사합니다.

멈춰있는 URL을 그대로 브라우저로 열어도 그대로 멈춰있는 현상이 있구요..

대신 처음부터 브라우저로 열면 최종페이지까지 잘 도달합니다...
0 추천
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<script type='text/javascript'>
function htmlspecialchars(str){  
    str = str.replace(/</g, '&lt;');
    str = str.replace(/>/g, '&gt;');
    str = str.replace(/"/g, '&quot;');
    str = str.replace(/'/g, '&#039;');
    return str;
}

function bol(){
    if (top.location != self.location) {
        return false;
    }

    var qs = location.search.split("?")[location.search.split("?").length-1].split("&");
    qso = {};
    for (var i=0; i<qs.length; i++){
        if (qs[i]!="") {
            var tmpa = qs[i].split("=");
            qso[tmpa[0]] = tmpa[1] ? tmpa[1] : "";
        }
    }
    
    var tu = unescape(qso.tu);
    if (htmlspecialchars(tu).length != tu.length) {
        exit;
    }
    
    if (qso.tu && (qso.tu.indexOf("http%3A%2F%2Fs.click.taobao.com%2F")===0
                || qso.tu.indexOf("http%3A%2F%2Fi.click.taobao.com%2F")===0
                || qso.tu.indexOf("http%3A%2F%2Fs.click.alimama.com%2F")===0
                || qso.tu.indexOf("http%3A%2F%2Fitem8.taobao.com%2F")===0
                || qso.tu.indexOf("http%3A%2F%2Fshop8.taobao.com%2F")===0)) {
        if (!window.attachEvent) {
            document.write('<input style="display:none" type="button" id="exe" value="" onclick="window.location=\''+unescape(qso.tu)+'\'">');
            document.getElementById('exe').click();
        } else {
            document.write('<a style="display:none" href="'+unescape(qso.tu)+'" id="exe"></a>');
            document.getElementById('exe').click();
        }
    }
}//end of bol()
bol();
</script>
</body>
</html>

직전 소스코드가 이런식이네요..

마지막에 링크를 생성하고 클릭을 실행했는데,.. 이런 자바스크립트 코드가 webview에서 실행되지 않는건가요?

당그니2 (200 포인트) 님이 2013년 11월 25일 답변
...