Go to page HTML 1 page HTML 2, and traditional values

Go to page HTML 1 page HTML 2, and traditional values

1.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>1</title>
    </head>
    <body>
        <!-- 点击跳转 -->
        <input type="button" id="jump" value="To 2.html">
        
        <script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                
                $("#jump").click(function() {
                    window.location.href = "2.html?id=123"; // 跳转至 2.html 页面,并传入参数 id=123
                });
            });
        </script>
    </body>
</html>

2.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>2</title>
    </head>
    <body>
        <p>2.html</p>
        
        <script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                
                console.log(window.location.href);
                console.log(window.location.href.split("?")[1]);
            });
        </script>
    </body>
</html>

test

Click the button 1.html page:
Here Insert Picture Description

Jump to:
Here Insert Picture Description

reference

Pass values ​​from one html page to another page, another page received (by value which is transmitted in the form url)

decodeURI ()

Published 55 original articles · won praise 0 · Views 3176

Guess you like

Origin blog.csdn.net/qq_29761395/article/details/104204086