JS第二章:BOM

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
html:
百度
删除
关闭
打开

JS:
function baidu(){
alert("访问百度")
window.lacation="https://www.baidu.com/"

}
function del(){
if(confirm(“是否删除”)){
alert(“确定删除”)
}else{
alert(“取消删除”)
}
}
function clo(){
close();//关闭,系统自带
}
function dakai(){
open(“Js.html”);
//open(“Js.html”,“新窗口”,“windth=200px,heighy=200px”);
open(“Js.html”,“新窗口”,“windth=200px,heighy=200px,top=300px,left=700px”);
}
html
location属性
刷新页面
替换页面
JS:
function go(){
//
location.href=“index.html”;
}
function flush(){//刷新页面
location.reload();
}
function tiHuan(){//替换页面
location.replace(“JS.html”);
}

html:
前进11
前进2
前进3

<p></p>
<button id="login">登录</button>
<br />
性别:<input type="radio" value="男" name="sex" />男
<input type="radio" value="女" name="sex" />女
<p></p>

JS:
window.onload=function(){
var login=document.getElementById('login');
var sex=document.getElementsByName('sex');
var a=document.getElementsByTagName('a');//弹出标签
login.onclick=function(){
	alert("登录成功");
	alert(sex[0].value);
	alert(sex[1].value);
	for(var i=0;i<a.length;i++){
		alert(a[i].innerHTML);
  }
}

}
html:
时钟

开始 停止 JS: window.οnlοad=function(){ var time=document.getElementById('time'); var clock=document.getElementById('clock'); var stop=document.getElementById('stop'); var i; time.οnclick=function(){ i=setInterval("time()",1000);//走动 } stop.οnclick=function(){ clearInterval(i); }

}

function time(){
var d=new Date();
var year=d.getFullYear();
var month=d.getMonth()+1;
var day=d.getDate();
var hour=d.getHours();
var minute=d.getMinutes();
var second=d.getSeconds();
clock.innerHTML=year+“年”+month+“月”+day+“日”+hour+":"+minute+":"+second;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值