B
bingLi
Unregistered / Unconfirmed
GUEST, unregistred user!
把一个能用的script改写为函数,在html外部调用,传递三个参数,但总
报错。请大家帮帮看一下。
//var no=3;
// snow number
//var speed=0.00001;
// smaller number moves the snow faster
//var snowflake = "fallleaf01.gif";
function slowdown(snowflake,speed,snowflake)
{
var ie4up=(document.all) ? 1:0;
var dx,xp,yp;
// coordinate and position variables
var am,stx,sty;
// amplitude and step variables
var i;
vardo
c_width,doc_height;
doc_width =do
cument.body.clientWidth;
doc_height =do
cument.body.clientHeight;
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
for (i = 0;
i < no;
++ i)
{
dx = 0;
// set coordinate variables
xp = Math.random()*(doc_width-50);
// set position variables
yp = Math.random()*doc_height;
am = Math.random()*20;
// set amplitude variables
stx = 0.02 + Math.random()/10;
// set step variables
sty = 0.7 + Math.random();
// set step variables
if (i==0)
{
do
cument.write("<div id=/"dot"+ i +"/" style=/"POSITION: ");
do
cument.write("absolute;
Z-INDEX: "+ i +";
VISIBILITY: ");
do
cument.write("visible;
TOP: 15px;
LEFT: 15px;/"><img src=/"");
do
cument.write(snowflake + "/" border=/"0/"></div>");
}
else
{
do
cument.write("<div id=/"dot"+ i +"/" style=/"POSITION: ");
do
cument.write("absolute;
Z-INDEX: "+ i +";
VISIBILITY: ");
do
cument.write("visible;
TOP: 15px;
LEFT: 15px;/"><img src=/"");
do
cument.write(snowflake + "/" border=/"0/"></div>");
}
}
function snowIE() {
for (i=0;
i<no;
++i)
{
yp += sty;
if (yp >do
c_height-50)
{
xp = Math.random()*(doc_width-am-30);
yp = 0;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
do
c_width =do
cument.body.clientWidth;
do
c_height =do
cument.body.clientHeight;
}
dx += stx;
do
cument.all["dot"+i].style.pixelTop = yp;
do
cument.all["dot"+i].style.pixelLeft = xp + am*Math.sin(dx);
}
setTimeout("snowIE()", speed);
}
snowIE();
}
报错。请大家帮帮看一下。
//var no=3;
// snow number
//var speed=0.00001;
// smaller number moves the snow faster
//var snowflake = "fallleaf01.gif";
function slowdown(snowflake,speed,snowflake)
{
var ie4up=(document.all) ? 1:0;
var dx,xp,yp;
// coordinate and position variables
var am,stx,sty;
// amplitude and step variables
var i;
vardo
c_width,doc_height;
doc_width =do
cument.body.clientWidth;
doc_height =do
cument.body.clientHeight;
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
for (i = 0;
i < no;
++ i)
{
dx = 0;
// set coordinate variables
xp = Math.random()*(doc_width-50);
// set position variables
yp = Math.random()*doc_height;
am = Math.random()*20;
// set amplitude variables
stx = 0.02 + Math.random()/10;
// set step variables
sty = 0.7 + Math.random();
// set step variables
if (i==0)
{
do
cument.write("<div id=/"dot"+ i +"/" style=/"POSITION: ");
do
cument.write("absolute;
Z-INDEX: "+ i +";
VISIBILITY: ");
do
cument.write("visible;
TOP: 15px;
LEFT: 15px;/"><img src=/"");
do
cument.write(snowflake + "/" border=/"0/"></div>");
}
else
{
do
cument.write("<div id=/"dot"+ i +"/" style=/"POSITION: ");
do
cument.write("absolute;
Z-INDEX: "+ i +";
VISIBILITY: ");
do
cument.write("visible;
TOP: 15px;
LEFT: 15px;/"><img src=/"");
do
cument.write(snowflake + "/" border=/"0/"></div>");
}
}
function snowIE() {
for (i=0;
i<no;
++i)
{
yp += sty;
if (yp >do
c_height-50)
{
xp = Math.random()*(doc_width-am-30);
yp = 0;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
do
c_width =do
cument.body.clientWidth;
do
c_height =do
cument.body.clientHeight;
}
dx += stx;
do
cument.all["dot"+i].style.pixelTop = yp;
do
cument.all["dot"+i].style.pixelLeft = xp + am*Math.sin(dx);
}
setTimeout("snowIE()", speed);
}
snowIE();
}