zoukankan      html  css  js  c++  java
  • 浏览器--浏览器对象

    window

    innerWidthinnerHeight属性,可以获取浏览器窗口的内部宽度和高度。内部宽高是指除去菜单栏、工具栏、边框等占位元素后,用于显示网页的净宽。

    还有一个outerWidthouterHeight属性,可以获取浏览器窗口的整个宽高。

    navigator

    navigator对象表示浏览器的信息,最常用的属性包括:

    • navigator.appName:浏览器名称;
    • navigator.appVersion:浏览器版本;
    • navigator.language:浏览器设置的语言;
    • navigator.platform:操作系统类型;
    • navigator.userAgent:浏览器设定的User-Agent字符串。

    screen

    screen对象表示屏幕的信息,常用的属性有:

    • screen.width:屏幕宽度,以像素为单位;
    • screen.height:屏幕高度,以像素为单位;
    • screen.colorDepth:返回颜色位数,如8、16、24。

    location

    location对象表示当前页面的URL信息。

    http://www.example.com:8080/path/index.html?a=1&b=2#TOP
    location.protocol; // 'http'
    location.host; // 'www.example.com'
    location.port; // '8080'
    location.pathname; // '/path/index.html'
    location.search; // '?a=1&b=2'
    location.hash; // 'TOP'

    要加载一个新页面,可以调用location.assign()

    如果要重新加载当前页面,调用location.reload()方法非常方便。

    document

    document对象表示当前页面。由于HTML在浏览器中以DOM形式表示为树形结构,document对象就是整个DOM树的根节点。

    documenttitle属性是从HTML文档中的<title>xxx</title>读取的,但是可以动态改变:

    document对象提供的getElementById()getElementsByTagName()可以按ID获得一个DOM节点和按Tag名称获得一组DOM节点。

    document对象还有一个cookie属性,可以获取当前页面的Cookie。

    history

    history对象保存了浏览器的历史记录,JavaScript可以调用history对象的back()forward (),相当于用户点击了浏览器的“后退”或“前进”按钮。

    这个对象属于历史遗留对象,简单粗暴地调用history.back()可能会让用户感到非常愤怒。

    原文地址:https://www.liaoxuefeng.com/wiki/1022910821149312/1023022272084160

  • 相关阅读:
    PHP中读写文件
    Java和PHP在Web开发方面的比较
    CentOS yum安装 Apache + PHP + MySQL
    PHP 时间参数大全
    数据库结果太大,PHP超出内存限制
    PHP扩展配置?
    php 实现KMP算法
    OS + Linux Shell bash / sh / ksh / csh / tcsh / adb shell
    my soft / text tools / EmEditor / Notepad++ / UltraEdit / EditPlus / Sublime Text
    JAVA EE Projects_sourceforge
  • 原文地址:https://www.cnblogs.com/liangtao999/p/11789380.html
Copyright © 2011-2022 走看看