日期:2014-05-16 浏览次数:20390 次
<!DOCUTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<input type="button" id="create_div" value="点我弹出小窗口" />
<script type="text/javascript">
window.onload = function(){
document.getElementById('create_div').onclick = function(){
var div = document.createElement('div');
div.style.position = 'absolute';
div.style.top = random()+'px';
div.style.left = random()+'px';
div.style.width = '200px';
div.style.height = '200px';
div.style.border = '1px solid #999';
div.style.background = 'blue'
document.body.appendChild(div) ;
}
function random(){
return parseInt(Math.random()*1000);
}
}
</script>
</body>
</html>