<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body >
<script>
window.οnlοad=dingshiqi();
function dingshiqi(){
document.body.bgColor="black";
setInterval("show()",1000);
}
function show(){
var img=document.createElement('img');
img.setAttribute('src','xingxing.gif');
var width=GetRandom(20,500);
var height=GetRandom(20,500);
img.setAttribute("width",width);
img.setAttribute("height",height);
var x=GetRandom(0,window.innerWidth);//随机生成窗体宽度
var y=GetRandom(0,window.innerHeight);//随机生成窗体高度
img.setAttribute("style","position:absolute;left:"+x+"px;top:"+y+"px;");//修改style属性
document.body.appendChild(img);
img.setAttribute("onclick","del(this)");
function GetRandom(min,max){
return Math.floor((Math.random()*((max+1)-min)+min));
}
}
alert("消灭一个10分")
var i=0;
function del(obj){
document.body.removeChild(obj);
i++;
console.log("消灭个数"+i);
console.log("得分"+i*10);
}
dingshiqi();
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body >
<script>
window.οnlοad=dingshiqi();
function dingshiqi(){
document.body.bgColor="black";
setInterval("show()",1000);
}
function show(){
var img=document.createElement('img');
img.setAttribute('src','xingxing.gif');
var width=GetRandom(20,500);
var height=GetRandom(20,500);
img.setAttribute("width",width);
img.setAttribute("height",height);
var x=GetRandom(0,window.innerWidth);//随机生成窗体宽度
var y=GetRandom(0,window.innerHeight);//随机生成窗体高度
img.setAttribute("style","position:absolute;left:"+x+"px;top:"+y+"px;");//修改style属性
document.body.appendChild(img);
img.setAttribute("onclick","del(this)");
function GetRandom(min,max){
return Math.floor((Math.random()*((max+1)-min)+min));
}
}
alert("消灭一个10分")
var i=0;
function del(obj){
document.body.removeChild(obj);
i++;
console.log("消灭个数"+i);
console.log("得分"+i*10);
}
dingshiqi();
</script>
</body>
</html>