Javascript学习笔记(7_1) ---Js中的BOM

Js中的BOM

一、什么是BOM

B  brower

O  object

M  model

浏览器对象模型

二、window对象下的属性或者方法

window.open()==è打开一个页面

         格式:window.open(url 地址,打开方式,设置参数,是否替换原有页面);

         Window.close ==è关闭页面

存在问题:

扫描二维码关注公众号,回复: 1601845 查看本文章

在火狐浏览器里关闭不了:Scriptsmay close only the windows that were opened by it.

*************************注意***************************

1》  在全局下 ,声明变量或者函数,都是属于window对象的

2》  单击事件格式:

元素.onclick = function(){

点击后执行的代码

}

三、history 子对象:浏览器历史记录对象

length 表示当前页面的历史记录条数

back():返回上一条历史记录页面

forword():返回下一条历史记录页面

go(): 进入指定的历史记录页面

         go()常用的方法就是go(1)和go(-1)

         go(1)相当于forward()函数

         go(-1)相当于 back()函数

四、location 子对象:浏览器位置信息对象

hash 获取URL 锚点之后的内容,主要用来获取锚点名

         锚点就是#

host:返回域名和端口信息

href:用于获取或者设置当前页面的完整URL地址

         location.href= ‘a.html’ -à跳转到a.html页面中

         location.href==è获取到url

search:获取页面get传参值的字符串

五、Navigator 子对象:浏览器信息检测对象

userAgent 用户代理信息,返回客户端发送给服务器的user-agent头信息,常用于浏览器版本检测等…不需要记

language:浏览器的语言

platform:平台信息

六、Screen 子对象:获取屏幕的子对象

width:当前屏幕分辨率的宽度

height 当前屏幕分辨率的高度

七、定时器:间歇调用

格式:

setInteval(函数,毫秒);

八、停止定时器

格式:

clearInteval(timer)

九、超时调用

格式:

setTimeout(函数,毫秒)

/*var a = 10;
alert(window.a)
//你的桌子
//你的笔记本
function fn(){
	alert('函数')
}
window.fn()
*/
/*window.open("index1.html","_blank",
"width=300 ,height=300,top=50,left=120");*/
//1》知道点击的是谁
//2》点击谁,实现什么样功能
/*btn.onclick = function(){
	window.open("index1.html","_blank","width=300 ,height=300,top=50,left=120");
//	alert(1)
//	window.close();
}*/

/********************history子对象*********************/
//alert(history.length);	//历史记录的条数
//history.forward();	//进入下一条历史记录页面
//history.go(1)

/***************************location 子对象:浏览器位置信息对象*************/

/*btn3.onclick = function(){
//	alert(location.href)
	if(userName.value == 'admin'){
		location.href = 'http://127.0.0.1:8020/javascript/07/index1.html'
	}
}*/

/*btn3.onclick = function(){
	alert(location.hash)//获取锚定之后的内容  #号后取到
	alert(location.search)//获取页面get传参值的字符串 取到?号之后内容 #号后取不到
}*/

/***************Navigator 子对象:浏览器信息检测对象**************/

//alert(navigator.userAgent);//用户代理信息
//alert(navigator.language); //浏览器语言
//alert(navigator.platform); //平台信息

/***************Screen 子对象:获取屏幕的子对象**************/

//alert(screen.width);//当前屏幕分辨率的宽度 和浏览器大小没有关系
//alert(screen.height);
//alert(screenLeft); //浏览器到屏幕左边的距离
//alert(screenTop); //浏览器到屏幕上方的距离

/****************定时器:间歇调用*************/
/*setInterval(function(){
	alert(1)
},1000) ;//参数:函数、毫秒
*/
function demo(){
	document.write(1);
}

var timer = setInterval(demo,500)

clearInterval(timer)
setTimeout(function(){
	document.write(1)
},500)

猜你喜欢

转载自blog.csdn.net/weixin_39209728/article/details/80635501
今日推荐