zoukankan      html  css  js  c++  java
  • 11.27 window对象

    Window对象
    属性:innerHeight 返回窗口的文档显示区的高度
      innerWidth 宽度
      outerHeight 返回窗口的尾部高度(浏览器的高度)
      outerWidth 宽度
      length 设置或返回窗口中的框架数量
      name 返回或设置窗口做的名称
    window.open() 打开新的网页,第二个参数就是此网页的name
      frame里面,name属性
    方法; close() 关闭浏览器窗口
    alert() 警告框
    confirm() 显示确认和取消按钮的对话框
    prompt() 显示用户输入的对话框
    open() 打开一个新浏览器窗口或查找已命名的窗口
    resizeBy()按照指定像素调整窗口大小
    resizeTo()把窗口的大小调整到的宽高
    scrollBy()按照指定的系那个苏来滚动内容
    scrollTo()按照内容滚动到指定的位置

    navigator 对象通常用于浏览器与操作系统的版本
    appCodeName 返回浏览器的代码名
    appVersion 次级版本
    apppName 名称
    language 语言
    platform 返回运行浏览器操作系统平台

    document对象
    window.document.属性
    属性:document.cookie 获取或设置cookile
      document.title title
      document.URL URL

      location对象包含有关当前URL的信息
      hash 设置或返回从(#)开始的URL
      host 主机名和当前URL的端口号
      hostname URL的主机名
      href 完整的 URL
      pathname 当前URL的路径部分
      port 当前URL的端口号
      protocol URL的协议(http / https)
      search 从(?)开始的URL(查询部分)

    /协议(http)+URL的主机名+URL的端口号+URL的路径部分+(?)开始的URL+(#)开始的 URL
      console.log(location.protocol+'//'+location.hostname+':'+location.port +location.pathname+location.search+location.hash);

    window其他对象
    window.document.方法
    方法:assgin() 加载新的文档 (加载没有记录)
      reload()重新加载当钱文档
      replace()用新的文档替换当前文档

    screen对象 包含有关客户端显示屏幕的信息
    window.screen.属性
    属性:height 返回屏幕的高度
      width 返回屏幕的宽度
      availHeight 返回屏幕的高度(除windows任务栏之外)
      availWidth 宽度

    body对象
    window.document.body.属性
    属性:clientWidth 网页可见区域宽度
      clientHeight 网页可见区域高度
      scrollHeight 网页中文全文高度
      scrollWidth 网页中文全文宽度
      scrollTop 网页被卷去的高度
      scrollleft 网页被卷去的宽度

    案例:

       <script>
    window.onload=function(){
    //window对象
    console.log(window.innerHeight);
    console.log(window.innerWidth);
    console.log(window.outerHeight);
    console.log(window.outerWidth);
    console.log(window.length);
    //
    // var tag = window.confirm('你是否关闭页面');
    // if(tag ==true){
    // alert('您确定关闭页面?');
    // window.close();
    // }else{
    // alert('您已取消关闭页面')
    // }
    //
    // window.open('window_new.html','','width=300,height=300');
    //navigator对象
    console.log(window.navigator.appCodeName);
    console.log(window.navigator.appName);
    console.log(window.navigator.appVersion);
    console.log(window.navigator.language);
    console.log(window.navigator.platform);
    //document对象
    console.log(window.document.cookie);
    console.log(window.document.title='标题');
    console.log(window.document.URL);
    // Location对象
    console.log(location);
    console.log(location.hash);
    console.log(location.host);
    console.log(location.hostname);
    console.log(location.href);
    console.log(location.pathname);
    console.log(location.port);
    console.log(location.protocol);
    console.log(location.search);
    //协议(http)+URL的主机名+URL的端口号+URL的路径部分+(?)开始的URL+(#)开始的URL
    console.log(location.protocol+'//'+location.hostname+':'+location.port+location.pathname+location.search+location.hash);

    // window.location.assign('https://www.baidu.com');
    // window.location.reload();
    // window.location.replace('https://www.baidu.com');
    //body对象
    console.log(window.document.body.clientHeight);
    console.log(window.document.body.clientWidth);
    console.log(window.document.body.scrollWidth);
    console.log(window.document.body.scrollHeight);
    console.log(window.document.body.scrollTop);
    //滚动条距离下部的高度
    //网页正文-页面显示高度-网页被卷去的高度
    console.log(window.document.body.scrollHeight-window.innerHeight-window.document.body.scrollTop);

    }
      </script>
  • 相关阅读:
    Git第一次新建项目添加ssh key
    第一次将本地项目同步到git服务器
    python实现差分隐私Laplace机制
    利用皮尔逊相关系数找出与目标最相关的特征(Python实现)
    corrcoef函数python_用Numpy计算Python中的Pearson相关系数
    Python Numpy库 numpy.corrcoef()函数讲解
    皮尔森相关系数(Pearson correlation coefficient)
    Python三种方法计算皮尔逊相关系数(Pearson correlation coefficient)
    特征选择 (feature_selection)
    基于模型的特征选择详解
  • 原文地址:https://www.cnblogs.com/xiaoxiongv1/p/7905579.html
Copyright © 2011-2022 走看看