zoukankan      html  css  js  c++  java
  • BOM

    BOM (Browser Object Model)

    浏览器对象模型
    BOM是关于浏览器的方法,属性,事件
    
    一、方法
    • window.open() 打开一个新窗口,返回新打开的窗口对象

    1.指定要打开的页面地址。

    window.open("http://www.miaov.com");
    如果不写http代表打开的是本地地址
    
    window.open("pleaseOpenMe.html");
    
    

    2.打开方式:

    _blank _self ... iframName
    window.open("pleaseOpenMe.html","_blank");//在新窗口中打开网址
    
    window.open("pleaseOpenMe.html","_self");//在当前页面中打开网址
    
    window.open("pleaseOpenMe.html","f1");//在iframe页面中打开网址
    

    3.浏览器的窗口特征 (宽,高,窗口位置等)

    注意: 当设置第三个参数的时候,第二个参数必须要是"_blank"

    window.open("pleaseOpenMe.html","_blank","width=300px,height=100px");//在新窗口中打开网址
    

    4.不传入参数,默认打开新的空白页面

    	\ 默认打开新的空白页面
    	window.open();
    
    二、属性
    1. window.location.hash

      锚点信息(#号后面的所有内容)
      http://bbs.miaov.com/forum.php?mod=forumdisplay#fid=7&page=5?mod=forumdisplay

      fid=7&page=5

      为hash赋值,不会刷新页面

      hash 和 search 都是可以获取并且设置的

    2. window.location.search
      查询字符串
      在url中,从?到#之间的内容

    search
    地址栏查询信息(问号到#号之间的所有内容)

    • 可以读,写
    • 但是 为search 赋值 的时候会刷新页面 注意:设置search最好通过事件来实现(比如加在点击事件中)

    onhashchange事件

    当页面的hash发改变的时候,触发这个事件

    window.onhashchange = function(){
    	console.log( "hash值改变了" );
    }
    

    window.navigator.userAgent

    用户代理信息

    操作系统 、 浏览器内核 、浏览器版本等

    返回的是字符串

  • 相关阅读:
    【Jenkins】jenkins 配置腾讯企业邮箱
    Monkey 用户指南(译)
    Windows,easygui 安装
    python笔记:list--pop与remove的区别
    递归--Java_汉诺塔
    appium安装 For windows
    【web开发--js学习】functionName 如果是一个属性值,函数将不会被调用
    python爬取煎蛋网图片
    pv&pvc
    docker
  • 原文地址:https://www.cnblogs.com/learning-/p/7267971.html
Copyright © 2011-2022 走看看