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吧 取出来再循环 用javascript怎样实现DW属性面板中的链接作用 运行这段javascript为什么显示link1没有定义? 我不知道怎么形容我的问题,请各位帮忙 JSP调用javascript问题 用javascript控制Radio的隐藏和显示 ------------------------------------------------靠~ 这也行??? 又遇到问题了 加载某一jsp文件的时候,能否设定它自动加载某一js语句! 请教!csdn网站的里用到的源代码。 iframe奇怪的问题(背景) 收集幻灯片程序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>