BOM的内置方法内置对象体验

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <a href="javascript:;">点击我可以穿件一个新的页面</a>
    <a href="javascript:;">点击我可以关闭本页面</a>
    <div>点击我跳转到百度</div>
    <script>
        //新窗口 = window.open(地址,是否开新窗口,新窗口的参数);
        var a1 = document.getElementsByTagName("a")[0];
//        var a2 = document.getElementsByTagName("a")[1];
        a1.onclick = function () {
//            window.open("http://www.jd.com","_blank");
            var json = {"name":"helloworld","fullscreen":"no","location":"no","width":"100px","height":"100px","top":"100px","left":"100px"};
//            var newWin = window.open("demo.html","_self",json);
            var newWin = window.open("demo.html","_blank",json);
            newWin.moveTo(500,500);

//            name:新窗口的名称,可以为空
//            featurse:属性控制字符串,在此控制窗口的各种属性,属性之间以逗号隔开。
//        fullscreen= { yes/no/1/0 } 是否全屏,默认no
//        channelmode= { yes/no/1/0 } 是否显示频道栏,默认no
//        toolbar= { yes/no/1/0 } 是否显示工具条,默认no
//        location= { yes/no/1/0 } 是否显示地址栏,默认no
//        directories = { yes/no/1/0 } 是否显示转向按钮,默认no
//        status= { yes/no/1/0 } 是否显示窗口状态条,默认no
//        menubar= { yes/no/1/0 } 是否显示菜单,默认no
//        scrollbars= { yes/no/1/0 } 是否显示滚动条,默认yes
//        resizable= { yes/no/1/0 } 是否窗口可调整大小,默认no
//        width=number 窗口宽度(像素单位)
//        height=number 窗口高度(像素单位)
//        top=number 窗口离屏幕顶部距离(像素单位)
//        left=number 窗口离屏幕左边距离(像素单位)
        }
//
//        //关闭本页面
//        a2.onclick = function () {
//            window.close();
//        }


    var div = document.getElementsByTagName("div")[0];
        div.onclick = function () {
            location.href = "http://www.baidu.com";
//            window.open("http://www.baidu.com","_blank");
        }
//        console.log(location.href    )    //
//        console.log(location.hash    )    //    返回url中#后面的内容,包含#
//        console.log(location.host    )    // 主机名,包括端口
//        console.log(location.hostname)    // 主机名
//        console.log(location.pathname)    // url中的路径部分
//        console.log(location.protocol)    // 协议 一般是http、https
//        console.log(location.search   )     // 查询字符串


        //navigator
//        console.log(navigator.userAgent);
//        console.log(navigator.platform);

        //回退
        //history.go(-1);
//        history.back();


    </script>

</body>
</html>

猜你喜欢

转载自blog.csdn.net/sky6even/article/details/80767945