点出满天小星星 不懂多敲几遍即可
<html onclick="init(event)">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
//实例:点出满天星星
/*
(1)当onclick事件发生时(点击html标记),去显示一个星星
*/
function init(e)
{
//创建图片
var imgObj = document.createElement("img");
//追加到<body>节点下
document.body.appendChild(imgObj);
//增加src属性
imgObj.src = "images/xingxing.gif";
//增加width属性
var width = getRandom(15,85);
imgObj.width = width;
//增加style属性
var x = e.clientX ? e.clientX : event.clientX;
var y = e.clientY ? e.clientY : event.clientY;
imgObj.style.position = "absolute";
imgObj.style.left = x - width/2 + "px";
imgObj.style.top = y - width/2 + "px";
}
function getRandom(min,max)
{
var random = Math.random()*(max-min)+min;
random = Math.floor(random);
return random;
}
</script>
</head>
<body bgColor="#000">
</body>