window对象

来源:互联网 发布:电商运营 知乎 编辑:程序博客网 时间:2024/06/03 17:14
<script>
1.window对象 screen:    window.screen.width;//screen.width    console.log(screen);    console.log("屏幕的总宽度"+screen.width);    console.log("屏幕的总高度"+screen.height);//    可用高度不包括底部任务拦。    console.log("屏幕的可用高度"+screen.availHeight);    console.log("屏幕的可用宽度"+screen.availWidth);    /*屏幕旋转角度 方向为逆时针旋转,竖屏显示的时候旋转角度为90deg.     * 当你的屏幕旋转完毕后,屏幕的高度和宽度属性和横屏时对换.*/    console.log("屏幕的旋转角度" + screen.orientation.angle);
2.window对象 location :
//    <!-- 完整路径-->    console.log("完整路径href:" +  location.href);//       安全协议console.log("安全协议protocol:" + location.protocol);//       主机名称console.log("主机名称hostname:" + location.hostname);//        端口号console.log("端口号host:" + location.host);//      url路径console.log("url路径pathname:" + location.pathname);//      查询部分console.log("查询部分search:" + location.search);//      锚点部分console.log("锚点部分hash:" + location.hash);
//    <!-- assign加载新页面-->    function assignPage(){        location.assign("http://www.Baidu.com");    }    function reloadPage(){//        不是完全刷新会从缓存里加载已经存在的内容        location.reload();//        完全刷新   彻底刷新当前页面  不会从缓存里获取数据。        location.reload(true);    }//    替代页面  用一个新页面替代一个老页面 跳转到新页面后无法返回到老页面    function replacePage(){        location.replace("http://www.hao123.com")    }
3.window对象 history:
back();forward();go();
4.window对象 navigator:
   console.log(navigator);//    appName产品名称    console.log("产品名称appName:" + navigator.appName);//    appVersion版本号    console.log("版本号appVersion:" + navigator.appVersion);//    用户代理信息    console.log("用户代理信息userAgent:" + navigator.userAgent);//    系统平台    console.log("系统平台platform:" + navigator.platform);
</script>

原创粉丝点击