WebView之网络异常HTML编码

网络异常的网页编码:

    点击按钮重新加载,该网页获取请求参数参数reloadUrl

 // 本地文件处理       

 String str = "file:///android_asset/exception.html?reloadUrl="+"http://www.baidu.com";       

 mWebView.loadUrl(str); 

通过本地网页获取参数值,实现重新加载。

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <title></title>
    <style type="text/css">
        body {
            -webkit-user-select: none;
            -webkit-touch-callout: none;
            -webkit-tap-highlight-color: rgba(0,0,0,0);
            -webkit-text-size-adjust: none;
        }

        .main {
            width: 100%;
            height: 600px;
            text-align: center;
            background-color: #f8f8f8;
        }

        .pic {
            padding-top: 100px;
            padding-bottom: 30px;
        }

        .speak {
            color: #797979;
            font-size: 22px;
            font-weight: bolder;
            padding-bottom: 15px;
        }

        .desc {
            color: #bbb;
            font-size: 16px;
            padding-bottom: 15px;
            font-weight: bold;
        }

        .jump span {
            border-radius: 8px;
            padding: 3px 20px;
            color: #797979;
            font-size: 18px;
            border: 2px solid #a4a6ac;
        }
    </style>
</head>
<body>
    <div class="main">
        <div class="pic">
            <img src="C:\Users\Oscar.Chao\Desktop\prize\no_wifi.png" alt="无网络" />
        </div>
        <div class="speak">亲,您的手机网络不太好~</div>
        <div class="desc">请检查您手机的网络</div>
        <div class="jump"><span id="btnJump" οnclick="jlink()">重新加载</span></div>
    </div>
    <script type="text/javascript">
        function UrlSearch() {
            var name, value;
            var str = location.href;
            var num = str.indexOf("?");
            str = str.substr(num + 1);
            var arr = str.split("&");
            for (var i = 0; i < arr.length; i++) {
                num = arr[i].indexOf("=");
                if (num > 0) {
                    name = arr[i].substring(0, num);
                    value = arr[i].substr(num + 1);
                    this[name] = value;
                }
            }
        }
        function jlink() {
            var Request = new UrlSearch();
            if (Request.uri == undefined) { return; };
            location.href = Request.uri;
        }
    </script>
</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值