JS---BOM

BOM

1、open和close

<!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-8">

        <title>open和close</title>

    </head>

    <body>

        <script type="text/javascript">

            /*

                1、BOM编程中,window对象是顶级对象,代表浏览器窗口

                2、window有open和close方法,可以开启窗口和关闭窗口

            */

        </script>



        <input type="button" value="开启百度" onclick="window.open('http://www.baidu.com')"/>

        <input type="button" value="开启百度(当前窗口)" onclick="window.open('http://www.baidu.com','_self');"/>

        <input type="button" value="开启百度(新窗口)" onclick="window.open('http://www.baidu.com','_blank');"/>

        <input type="button" value="开启百度(父窗口)" onclick="window.open('http://www.baidu.com' ,'_parent')"/>

        <input type="button" value="开启百度(顶级窗口)" onclick="window.open('http://www.baidu.com','_top');"/>



        <input type="button" value="打开open" onclick="window.open('003、open.html');"/>

    </body>

</html>

2、弹出消息框和确认框

<!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-8">

        <title>弹出消息框和确认框</title>

    </head>

    <body>

        <script type="text/javascript ">

            function del() {

               /* var ok=window.confirm("确认删除数据吗??")

                if (ok){

                    alert('已成功删除')

                }else {

                    alert('已退出删除')

                }*/

                if (window.confirm("确认删除数据吗??")){

                    alert('已成功删除')

                }else {

                    alert('已退出删除')

                }

            }

        </script>

        <input type="button" value="弹出消息框" onclick="window.alert('消息框')">

        <input type="button" value="弹出消息框(删除)" onclick="del()">

    </body>

</html>

3、open


<!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-8">

        <title>open</title>

    </head>

    <body>

        <input type="button" value="关闭当前窗口" onclick="window.close()">

    </body>

</html>

4、将当前窗口设置为顶级窗口


<!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-8">

        <title>将当前窗口设置为顶级窗口</title>

    </head>

    <body>

        <script type="text/javascript">

            /*

                  如果当前窗口不是顶级窗口的话,将当前窗口设置为顶级窗口

            */

        </script>

        <iframe src="005.html" width="500px" height="500px"></iframe>

    </body>

</html>

5、005

<!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-8">

        <title>005</title>

    </head>

    <body>

        005页面

        <script type="text/javascript">

        /*

        如果当前窗口不是顶级窗口的话,将当前窗口设置为顶级窗口

        */

        function setTop() {

            /*      005打开的话

                    window是当前浏览器窗口,代表005.html

                    “当前窗口的顶级窗口”如果“不是自己”

                    window.top就是当前窗口对应的顶级窗口

                    window.self表示当前自己这个窗口

                    004.将当前页面设置为顶级窗口打开的话

                    window.top就是004

                    window.self表示005

            */

           // console.log((window.top!==window.self))

            if (window.top!==window.self){

                //将当前窗口设置为顶级窗口

                //window.top.location是005地址

                window.top.location=window.self.location;

            }

        }

        </script>

        <br><br>

        <input type="button" onclick="setTop()" value="如果当前窗口不是顶级窗口的话,将当前窗口设置为顶级窗口">

    </body>

</html>

6、history对象


<!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-8">

        <title>history对象</title>

    </head>

    <body>

        <a href="007.html">007页面</a>

        <input type="button" value="前进" onclick="window.history.go(1)"/>

    </body>

</html>

7、007

<!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-8">

        <title>007</title>

    </head>

    <body>

        007 page!

        <input type="button" value="后退" onclick="window.history.back()"/>

        <input type="button" value="后退" onclick="window.history.go(-1)"/>

    </body>

</html>

8、设置浏览器地址栏上的URL


<!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-8">

        <title>设置浏览器地址栏上的URL</title>

    </head>

    <body>

        <script type="text/javascript">

            function goBaidu(){

                //var locationObj = window.location;

                //locationObj.href="https://www.baidu.com/"

                window.location.href="https://www.baidu.com/"

            }

            function goWangyi() {

                document.location="https://www.126.com/"

            }

        </script>

        <input type="button" value="百度" οnclick="goBaidu()">

        <input type="button" value="网易" οnclick="goWangyi()">

    </body>

</html>

总结:有哪些可以通过浏览器往服务器发请求?

1、表单form的提交

2、超链接

3、document.location

4、window.location

5、window.open("url")

6、直接在浏览器地址栏上输入URL,然后回车,(这个也可以手动输入,提交也可以是动态的)

以上所有的请求方式均可以携带数据给浏览器,只有通过表单提交是动态的
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

洛尘~~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值