1.()在脚 本里要求不是很严格.
2.如果要那么写.可以写成这样:
<html><body onmousemove=gensui()>
<script languae=javascript>
function gensui()
{
var x=event.x;
var y=event.y;
document.all.layer1.style.left=x;
document.all.layer1.style.top=y;
}
//document.onmousemove=gensui;
</script>
<div id="layer1" style="position:absolute;left:100;top:100">
<font>hello</font>
</div>
</body>
</html>
2.如果要那么写.可以写成这样:
<html><body onmousemove=gensui()>
<script languae=javascript>
function gensui()
{
var x=event.x;
var y=event.y;
document.all.layer1.style.left=x;
document.all.layer1.style.top=y;
}
//document.onmousemove=gensui;
</script>
<div id="layer1" style="position:absolute;left:100;top:100">
<font>hello</font>
</div>
</body>
</html>
<script language=javascript>
function bian()
{
var x=event.x;
document.all.layer1.style.font-size=x;
}
document.onmousemove=bian;
</script>
<div id=layer1 style="position:absolute;font-size=100;color:yellow">
变
</div>
为什么这个“变”字不能随着鼠标的移动而变化大小?
样式表中的属性名在脚本中的书写格式有变化,主要是避免“-”的歧义
“-”后面的字母大写“-”不要
css style="font-size:100"
js style.fontSize = x;<script language=javascript>
function bian()
{
var x=event.x;
document.all.layer1.style.fontSize=x;
}
document.onmousemove=bian;
</script>
<div id=layer1 style="position:absolute;font-size:100;color:yellow">
变
</div>另外
1. document.onmousemove=gensui;中gensui后面为什么不要"()"?
因为这是设定该事件的处理程序,有"()"就要执行了2.还是这句,前面为什么要加一个document.?为什么不能直接写onmousemove=……?
需要知道是哪个(类)对象的事件
<div id=layer1 style="position:absolute;color=yellow">
颜色
</div>
然后怎么在JAVASCRIPT里改变它的值呢?
document.all.layer1.style.color=red(错!)
document.all.layer1.style.fontColor=red(还是错!)
??????