JavaScript中的location

location–浏览器地址
reload–刷新页面
传一个参数:true–缓存
assign–加载新的文档

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>location学习</title>
        <!--location--浏览器地址
        reload--刷新页面
          传一个参数:true--缓存
        assign--加载新的文档

        -->
        <script type="text/javascript">
            function testLocation(){
                location="http://www.baidu.com";
            }
            function testReload(){
                location.reload(true);
            }
            function testAssign(){
                location.assign("https://blog.csdn.net/qq_43090158/article/details/82226301")
            }

        </script>
    </head>
    <body>
        <input type="button" class="" value="测试location" onclick="testLocation()" /><br />
        <input type="button" class="" value="测试reload" onclick="testReload()" /><br />
        测试:<input type="text" /><br />
        <input type="button" class="" value="测试assign" onclick="testAssign()" /><br />


    </body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_43090158/article/details/82315862