JS BOM基础 全局对象 window location history screen navigator

Stella981
• 阅读 435

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

全局变量声明的两种方式:
1,window.变量名=值;
2,var 变量名=值;

全局函数声明的两种方式:
1,window.函数名=function(){}
2,function 函数名=function(){}

BOM是Browser Object Model的缩写,是浏览器对象模型
核心是window对象,所有的全局变量和全局函数都被归在了window上

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

使用超时调用执行间歇调用的操作。

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

 JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

JS BOM基础 全局对象  window location  history screen navigator

A: window是浏览器的一个实例
1,即是JS访问浏览器的一个接口。
2,又是ECMAScript的全局对象(global对象)

B: screen对象包含有关客户端显示屏幕的信息

C: location对象包含有关当前URL的信息

D: navigator对象包含有关浏览器的信息

E: history对象包含用户在浏览器中访问过的URL

========window全局对象==========

window全局对象
---1,声明变量----
全局变量声明的两种方式:
1,window.变量名=值;
2,var 变量名=值;

全局函数声明的两种方式:
1,window.函数名=function(){}
2,function 函数名=function(){}
---2,弹窗----
BOM是Browser Object Model的缩写,是浏览器对象模型
核心是window对象,所有的全局变量和全局函数都被归在了window上
在提示框中"\n"表示换行。

A:window.alert()弹出警告框 window是可以省略的
B:window.prompt()弹出输入框 window是可以省略的
C:window.confirm()弹出确认框 window是可以省略的

---3,计时器----
超时调用 间歇调用
setTimeout()方法用于指定的时间后执行一次代码:
var timer=setTimeout(fn,time) clearTimeout(timer)清除超时调用
setTimeout()方法用于指定的时间后执行一次代码
var timer=setInterval(fn,time) clearInterval(timer)清除间歇调用

---4,window.open/close()----
---window.open(openURL,name,parameters)---
window.open: 当网页加载完成时立即打开一个新窗口,
openURL:网页地址,相对地址/绝对地址
name:网页title标签的描述。
parameters:各种参数,属性和属性值之间用等号连接。如下:

width,height: 设置浏览器窗口宽高
top,left: 设置浏览器的位置
toolbar: 设置浏览器工具栏
menubar: 设置浏览器菜单栏
scrollbars: 设置浏览器滚动条(垂直和水平滚动条)
status: 设置浏览器状态栏
location: 储存位置

========location全局对象==========

//location 位置,未知参数
locatiion.href //返回当前页面的完整的URL(包括协议)。会返回一个历史记录
location.hash //返回指定锚点
location.host //返回服务器名称和端口号
location.hostname //返回无端口服务器名称
location.pathname //返回URL中的目录和文件名(不包括协议)
location.port //返回的端口号
location.portocol //返回协议
location.search //返回地址栏中问号后面的: ?id=55&name="zheng" 不存在则返回空。*/

========history全局对象========

history.back() 等价于 history.go(-1) 后退到历史记录的上一个页面
history.forward() 等价于 history.go(1) 前面到历史记录的下一个页面
history.go(n) n可以正数也可以是负数,正数表示前进,负数表示后退

========screen全局对象========

window.innerWidth 获得浏览器窗口宽度,滚动条除外,随窗口变化而变化 错误写法:console.log(window.width);
window.innerHeight 获得浏览器窗口高度,状态栏除外,随窗口变化而变化 错误写法:console.log(window.height);
screen表示屏幕,取屏幕的宽度的属性比较少用,了解即可。
screen.availWidth 获得设备屏幕宽度 固定不会改变的 等价于:console.log(screen.width);
screen.availHeight 获得设备屏幕高度 固定不会改变的 等价于:console.log(screen.height);

以下是针对文档进行取值:document.body
scrollWidth 等于 clientWidth
scrollWidth 表示网页正文宽度,包括滚动的滚动条
clientWidth 表示网页的可见宽度,包括滚动的滚动条

scrollHeight 等于 clientHeight
scrollHeight 表示网页正文高度,包括滚动的滚动条
clientHeight 表示网页的可见高度,包括滚动的滚动条

offsetWidth 表示网页可见区域的宽度,包括边框,包括滚动的滚动条
offsetHeight 表示网页可见区域的高度,包括边框,包括滚动的滚动条

========navigator全局对象========

//navigator.userAgent获取浏览器的名称,版本,引擎以及操作系统灯信息的内容。
//此外还可以识别是移动端还是PC端设备。

Document
华为手机

\============================

var timer=setTimeout(fn,time)超时调用 clearTimeout(timer)清除超时调用
var timer=setInterval(fn,time)间歇调用 clearInterval(timer)清除间歇调用

超时调用
超时调用使用递归可以实现间歇调用的操作。

setTimeout()方法用于指定的时间后执行一次代码,有两个参数:
第一个参数是要执行的函数或者执行脚本;
第二个参数是指延时指定时间;
定时器要取消的话用clearTimeout方法进行取消。

间歇调用
setInterval()方法用每隔指定的时间执行一次代码,有两个参数:
第一个参数是要执行的函数或者执行脚本;
第二个参数是周期性执行代码的时间间隔;
定时器要取消的话用clearInterval方法进行取消。

Document

\------------------- //使用间歇调用实现会闪烁的文字,很炫酷的。 闪烁的文字

会闪烁的文字

============
//location 位置,未知参数
locatiion.href //返回当前页面的完整的URL(包括协议)。会返回一个历史记录
location.hash //返回指定锚点
location.host //返回服务器名称和端口号
location.hostname //返回无端口服务器名称
location.pathname //返回URL中的目录和文件名(不包括协议)
location.port //返回的端口号
location.portocol //返回协议
location.search //返回地址栏中问号后面的: ?id=55&name="zheng" 不存在则返回空。*/

Document
重定向

==============
history.back() 等价于 history.go(-1) 后退到历史记录的上一个页面
history.forward() 等价于 history.go(1) 前面到历史记录的下一个页面
history.go(n) n可以正数也可以是负数,正数表示前进,负数表示后退

Document \================= 取屏幕宽高,浏览器宽高 Document

\================== //navigator.userAgent获取浏览器的名称,版本,引擎以及操作系统灯信息的内容。 //此外还可以识别是移动端还是PC端设备。 Document
点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Easter79 Easter79
2年前
swap空间的增减方法
(1)增大swap空间去激活swap交换区:swapoff v /dev/vg00/lvswap扩展交换lv:lvextend L 10G /dev/vg00/lvswap重新生成swap交换区:mkswap /dev/vg00/lvswap激活新生成的交换区:swapon v /dev/vg00/lvswap
Jacquelyn38 Jacquelyn38
2年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
Wesley13 Wesley13
2年前
Java获得今日零时零分零秒的时间(Date型)
publicDatezeroTime()throwsParseException{    DatetimenewDate();    SimpleDateFormatsimpnewSimpleDateFormat("yyyyMMdd00:00:00");    SimpleDateFormatsimp2newS
Stella981 Stella981
2年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Wesley13 Wesley13
2年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
2年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
2年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
2年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
3个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这