• BOM操作


    BOM操作可以获得游览器的页面大小(viewport 视口:不包括工具栏和滚动条)
           (1)ChromefirefoxsafariIE
            var h =window.innerHeight;
            var w = window.innerWidth;
            console.log(h);
            console.log(w);
            (2)IE 8.7.6.5
            document.documentElement.clientHeight;
             document.documentElement.clientWidth;
             或
             document.body.clientWidth;
             document.body.clientHeight;
     
            适配所有的游览器写法
            var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
            var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
     
     
             -------------window的一些方法-----------
            开启一个新的窗口
            var newwindow = window.open();
            console.log(newwindow);
            newwindow.document.write("hahha");
     
            关闭窗口
             window.close();
     
           设备的 分辨率
            document.write("宽度"+window.screen.availWidth);
            document.write("高度"+window.screen.availHeight);
     
     
         web 主机域名   
          document.write(location.hostname);
          当前网页的存放路径
          document.write(location.pathname);
          使用的协议  file/http: https/
          document.write(location.protocol);
     
            function jiazai() {
            var newWindow = window.open();
            加载一个新的页面  assign 分配
            newWindow.location.assign("http://www.baidu.com");
        }
     
     
            获得 游览器的属性 
            document.write("游览器的名称:"+navigator.appName+"<br>");
            document.write("浏览器版本:"+navigator.appVersion+"<br>");
            document.write("硬件平台:"+navigator.platform+"<br>");
            document.write("用户代理语言:"+navigator.systemLanguage+"<br>");
    -------------HISTORY-----------
    input type="button" value ="back" onclick="goBack()">
        <input type="button" value ="forward" onclick="goForward()">
        <a href="http://www.baidu.com">aaa</a>
        <script>
            function goBack() {
                //前一个
                window.history.back();
            }
     
            function goForward() {
                //下一个
                window.history.forward();
            }
  • 相关阅读:
    新年第一个工作日,淦一个扫码登录
    eltree 从叶子节点入手解决选中问题
    elcascader 级联选择器 :回显回显回显
    VueX Module:路过你,忘记你
    我变成了曾经最讨厌的模样:路由屎山有感,Next 你是风暴也是风暴眼
    取小数点后两位:打造一个自己的toFixed
    dayjs: 兄弟moment.js寄了,我还在
    前端鄙视题
    android WebView的配置
    springboot自定义通用枚举校验注解
  • 原文地址:https://www.cnblogs.com/cntt/p/6479604.html
Copyright © 2020-2023  润新知