WEB前端 | JS基础——(8)DOM

<!doctype html>
<html>
	<head>
		<meta charset="utf-8"/>
		<title>BOM</title>
		<script type="text/javascript">
			
		</script>
	</head>
	<body>
		
	</body>
	<script type="text/javascript">
		// BOM对象就是可以对浏览器进行操作的对象
		// JS里面所有的全局变量都是window对象的属性
		a = 40;
		console.log(window.a);
		window.a = 50;
		console.log(a);
		
		// 所有的函数都是window对象的属性(成员变量)
		function test() {
			console.log(this);
		}
		window.test();
		
		// 获取窗口高度
		document.write(window.innerHeight);
		document.write('<br/>');
		document.write(window.innerWidth);
		document.write('<br/>');
		// 不同的获取屏幕高度的方法
		document.write(document.documentElement.clientHeight);
		document.write('<br/>');
		document.write(document.body.clientHeight);
		document.write('<br/>');
		// 兼容不同浏览器的获取窗口高度的方法
		document.write(window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight);
		document.write('<br/>');
		// 整体宽高包括工具栏
		document.write('窗口整体宽度:' + window.outerWidth);
		document.write('<br/>');
		document.write('窗口整体高度:' + window.outerHeight);
		window.setTimeout(function(){
			// window.open
			// 打开窗口
//			var newWindow = open('https://www.baidu.com/','','width=100,height=100');
			// 关闭窗口
			// close();
			// resizeTo 是把窗口调整到多少
			// resizeBy 是把窗口增加多少,可以是负数代表减少
			newWindow.moveTo(300, 300);
			newWindow.resizeTo(100, 100);
			newWindow.resizeBy(100, 100);
		},2000);
		document.write('<br/>');
		document.write('屏幕宽度:' + screen.width + 'px<br/>');
		document.write('屏幕高度:' + screen.height + 'px<br/>');
		document.write('屏幕可用宽度:' + screen.availWidth + 'px<br/>');
		document.write('屏幕可用高度:' + screen.availHeight + 'px<br/>');
		// 显示一个确认框,在确认框内显示提示字符串,当用户单击“确定”按钮 时该方法返回true,单击“取消”时返回false。 
//		window.confirm('你是猪?') ;
		// 显示一个输入框,在输入框内显示提示字符串,在输入文本框显示缺省文本,并等待用户输入,当用户单击“确定”按钮时,返回用户输入的字符串,当 单击“取消”按钮时,返回null值。 
//		window.prompt('姓名'); 
		
	</script>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值