码迷,mamicode.com
首页 > Windows程序 > 详细

mui---window.location.href通过url传递参数

时间:2018-05-30 22:40:39      阅读:1259      评论:0      收藏:0      [点我收藏+]

标签:src   script   --   device   java   name   text   for   eve   

url_send_page.html(发送页面)

<!doctype html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <link href="css/mui.min.css" rel="stylesheet" />
    </head>

    <body>
        <button type="button" class="mui-btn mui-btn-blue">用window.location.href向recieve_page页面传值</button>
        <script src="js/mui.min.js"></script>
        <script type="text/javascript">
            mui.init();
            //window.location.href方式 
            document.getElementsByTagName(button)[0].addEventListener(tap, function() {
                window.location.href = encodeURI(recieve_page.html?cid=2&cname=zyz&rname=马克);
            });
        </script>
    </body>

</html>

 

url_recieve_page.html(接收页面)

<!doctype html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <link href="css/mui.min.css" rel="stylesheet" />
    </head>

    <body>
        <span id="span1">
            span1
        </span>
        <script src="js/mui.min.js"></script>
        <script type="text/javascript">
            mui.init();

            mui.ready(function() {
                //获得url参数值
                var url = decodeURI(window.location.href);
                var arr_para = url.split(?)[1].split(&);
                var result = ‘‘;
                for(var i = 0; i < arr_para.length; i++) {
                    result += arr_para[i] + <br>;
                }
                document.getElementById("span1").innerHTML = result;
            });
        </script>
    </body>

</html>

 

mui---window.location.href通过url传递参数

标签:src   script   --   device   java   name   text   for   eve   

原文地址:https://www.cnblogs.com/beast-king/p/9113735.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!