JS随机取数值并赋值 本帖最后由 abc54288 于 2010-03-14 17:50:35 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script> var top=Math.round(Math.random()*(1000-100))+100; var left=Math.round(Math.random()*(600-200))+200; alert(top+":"+left);</script> divid.style.top=xxx;divid.style.left=xxx; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>test </title><style>#test{ width:100px; height:100px; border:1px solid red;}</style></head> <body><div id="test"></div></body> </html><script> var top = Math.round(Math.random()*(1000-100))+100 + "" + "px"; var left = Math.round(Math.random()*(600-200))+200+ "" + "px"; document.getElementById("test").style.marginTop = top; document.getElementById("test").style.marginLeft = left;</script>这个比较完整 <div id="d">我是学习的……学无止境……</div><script type="text/javascript">function pos(){ var d=document.getElementById("d"); d.style.left=Math.round((Math.random()*900)+100); d.style.top=Math.round((Math.random()*400)+200); setTimeout("pos()",500);}window.onload=pos;</script> 如果这个ID这是这样的形式,如<DIV onmousedown=getFocus(this) id=cc{content.id}>那JS中就不能直接指定某一个ID了,该如何办呢? 那你就用document.getElementByTagName吧 取出来再循环 JS调用AS3的System.setClipboard问题 js缩放拖动图片功能,在图片超过2m时的问题 使用widgeditor遇到的问题。 怎样用JavaScript实现日期自动更新? 这个个代码为什么说对象不支持次属性或方法 如何使下拉菜单的值根据文本框的值实时改变而改变?? 谁能帮写下正则过滤哈? 请问如何调用function里面定义的“子function",暂且这么说,谢谢! help??????????????/急 sessionlistener里的sessiondestoryed的时候连接数据库 收集幻灯片程序js 图片切换
var top=Math.round(Math.random()*(1000-100))+100;
var left=Math.round(Math.random()*(600-200))+200;
alert(top+":"+left);
</script>
divid.style.left=xxx;
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test </title>
<style>
#test{
width:100px;
height:100px;
border:1px solid red;
}
</style>
</head>
<body>
<div id="test"></div>
</body>
</html>
<script>
var top = Math.round(Math.random()*(1000-100))+100 + "" + "px";
var left = Math.round(Math.random()*(600-200))+200+ "" + "px";
document.getElementById("test").style.marginTop = top;
document.getElementById("test").style.marginLeft = left;
</script>
这个比较完整
学无止境……
</div>
<script type="text/javascript">
function pos(){
var d=document.getElementById("d");
d.style.left=Math.round((Math.random()*900)+100);
d.style.top=Math.round((Math.random()*400)+200);
setTimeout("pos()",500);
}
window.onload=pos;
</script>