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:
时钟
}
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;
}