zoukankan      html  css  js  c++  java
  • 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();
            }
  • 相关阅读:
    使用Python画ROC曲线以及AUC值
    Machine Learning : Pre-processing features
    资源 | 数十种TensorFlow实现案例汇集:代码+笔记
    在 Mac OS X 终端里使用 Solarized 配色方案
    编译安装GCC 4.7.2
    Office -Word 公式插件Aurora的使用 ——在 Word 中插入 LaTex 公式
    LaTeX 写中文论文而中文显示不出来
    LaTeX 公式编辑之 把符号放在正下方
    Python 判断字符串是否含有指定字符or字符串
    Python 中使用 pandas Dataframe 删除重复的行
  • 原文地址:https://www.cnblogs.com/cntt/p/6479604.html
Copyright © 2011-2022 走看看