rect()的参数一回儿四个,一会儿三个?为什么?搞不懂请高手帮忙解析!!

<head>
<style>
<!--
.intro{
position:absolute;
left:0;
top:0;
layer-background-color:#33cc00;
background-color:#33cc00;
border:0.1px solid black
}
-->
</style>
</head>
<body>
<div id="i1" class="intro"></div><div id="i2" class="intro"></div>
<SCRIPT Language="JavaScript">
var speed=20
var temp=new Array()
var temp2=new Array()
if (document.layers){
for (i=1;i<=2;i++){
temp=eval("document.i"+i+".clip")
temp2=eval("document.i"+i)
temp.width=window.innerWidth
temp.height=window.innerHeight/2
temp2.top=(i-1)*temp.height
}
}
else if (document.all){
var clipbottom=document.body.offsetHeight/2,cliptop=0
for (i=1;i<=2;i++){
temp=eval("document.all.i"+i+".style")
temp.width=document.body.clientWidth
temp.height=document.body.offsetHeight/2
temp.top=(i-1)*parseInt(temp.height)
}
}
function openit(){
window.scrollTo(0,0)
if (document.layers){
temp[1].bottom-=speed
temp[2].top+=speed
if (temp[1].bottom<=0)
clearInterval(stopit)
}
else if (document.all){
clipbottom-=speed
cliptop+=speed
temp[1].clip="rect(0 auto "+clipbottom+" 0)"
temp[2].clip="rect("+cliptop+" auto auto )"
if (clipbottom<=0)
clearInterval(stopit)
}
}
function gogo(){
stopit=setInterval("openit()",1000)
}
gogo()
</SCRIPT>
</body>
这段代码是用javascript实现层从上下载入的特效,但是本人对代码中的rect(0 auto "+clipbottom+" 0)和
rect("+cliptop+" auto auto )这两句话不能理解。

慕田峪9158850
浏览 182回答 1
1回答

慕运维8079593

你可以看看rect函数的源码 或者把它贴出来看看js对函数参数数目不是很严格,如果是4个形参,你只传入3个实参,它就把第4个参数置为null,这个也是js多态的体现
打开App,查看更多内容
随时随地看视频慕课网APP