js加载完页面自动执行一次方法

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,user-scalable=no">
    <title>title</title>
</head>
<!--onload="jump()" 调用要执行的方法  -->
<body onload="jump()">

</body>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">

    function jump(){
        var email = getQueryVariable("email");
        var token = getQueryVariable("action_token");
        var event = getQueryVariable("event");
        var api_url = document.getElementById("apiurl").value();

        var u = navigator.userAgent, app = navigator.appVersion;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        if(isAndroid==1){
            window.location.href="lydia://wellaged/login?login_type=email&mail=" + email + "&action_token=" + token + "&event=" + event
            location.reload();
        } else(
            window.location.href= api_url + "/v1/login/email?type=login&login_type=email&mail=" + email + "&action_token=" + token + "&event=" + event
        )
    }
</script>
</body>
</html>

 

© 版权声明
THE END
喜欢就支持一下吧
分享