这是一段javascript广告代码:但不知道为什么图片一直老往下边飘,控制不住,高手帮忙,最好能给详细注视一下,呵呵,javascript有些不懂,还有那里手册可能查到那一些函数的意思啊,如:scrollLeft,clientWidth等函数的意思?
document.write("<div id=img22 style='Z-INDEX:100; LEFT:2px; WIDTH:100px; POSITION:absolute; TOP:43px; height:100px; visibility: visible;'>");
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"120\" height=\"84\"><param name=\"movie\" value=\"images/54.swf\"><param name=\"quality\" value=\"high\"><embed src=\"images/54.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"120\" height=\"84\"></embed></object>");
document.write("<div onMouseUp='turnit(img22);' style='CURSOR: hand;' align='right'><img src='/images/close_piao2.gif' width='42' height='14' border='0' alt='关闭广告'></div></div>");var xPos1 = 600;
var yPos11 = 400;
var step1 = 1;
var delay1 = 30;
var height1 = 0;
var Hoffset1 = 0;
var Woffset1 = 0;
var yon1 = 0;
var xon1 = 0;
var pause1 = true;
var interval1;
img22.style.top = yPos11;
function changePos1()
{
width1 = document.body.clientWidth;
height1 = document.body.clientheight;
Hoffset1 = img22.offsetheight;
Woffset1 = img22.offsetWidth;
img22.style.left = xPos1 + document.body.scrollLeft;
img22.style.top = yPos11 + document.body.scrollTop;
if (yon1)
{yPos11 = yPos11 + step1;}
else
{yPos11 = yPos11 - step1;}
if (yPos11 < 0)
{yon1 = 1;yPos11 = 0;}
if (yPos11 >= (height1 - Hoffset1))
{yon1 = 0;yPos11 = (height1 - Hoffset1);}
if (xon1)
{xPos1 = xPos1 + step1;}
else
{xPos1 = xPos1 - step1;}
if (xPos1 < 0)
{xon1 = 1;xPos1 = 0;}
if (xPos1 >= (width1 - Woffset1))
{xon1 = 0;xPos1 = (width1 - Woffset1); }
}
function start1()
{
img22.visibility = "visible";
interval1 = setInterval('changePos1()', delay1);
}
function pause1_resume1()
{
if(pause1)
{
clearInterval(interval1);
pause1 = false;}
else
{
interval1 = setInterval('changePos1()',delay1);
pause1 = true;
}
}
start1();
document.write("<div id=img22 style='Z-INDEX:100; LEFT:2px; WIDTH:100px; POSITION:absolute; TOP:43px; height:100px; visibility: visible;'>");
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"120\" height=\"84\"><param name=\"movie\" value=\"images/54.swf\"><param name=\"quality\" value=\"high\"><embed src=\"images/54.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"120\" height=\"84\"></embed></object>");
document.write("<div onMouseUp='turnit(img22);' style='CURSOR: hand;' align='right'><img src='/images/close_piao2.gif' width='42' height='14' border='0' alt='关闭广告'></div></div>");var xPos1 = 600;
var yPos11 = 400;
var step1 = 1;
var delay1 = 30;
var height1 = 0;
var Hoffset1 = 0;
var Woffset1 = 0;
var yon1 = 0;
var xon1 = 0;
var pause1 = true;
var interval1;
img22.style.top = yPos11;
function changePos1()
{
width1 = document.body.clientWidth;
height1 = document.body.clientheight;
Hoffset1 = img22.offsetheight;
Woffset1 = img22.offsetWidth;
img22.style.left = xPos1 + document.body.scrollLeft;
img22.style.top = yPos11 + document.body.scrollTop;
if (yon1)
{yPos11 = yPos11 + step1;}
else
{yPos11 = yPos11 - step1;}
if (yPos11 < 0)
{yon1 = 1;yPos11 = 0;}
if (yPos11 >= (height1 - Hoffset1))
{yon1 = 0;yPos11 = (height1 - Hoffset1);}
if (xon1)
{xPos1 = xPos1 + step1;}
else
{xPos1 = xPos1 - step1;}
if (xPos1 < 0)
{xon1 = 1;xPos1 = 0;}
if (xPos1 >= (width1 - Woffset1))
{xon1 = 0;xPos1 = (width1 - Woffset1); }
}
function start1()
{
img22.visibility = "visible";
interval1 = setInterval('changePos1()', delay1);
}
function pause1_resume1()
{
if(pause1)
{
clearInterval(interval1);
pause1 = false;}
else
{
interval1 = setInterval('changePos1()',delay1);
pause1 = true;
}
}
start1();
ClientWidth,浏览器用户区域宽度,不含滚动的距离 .
height1 = document.body.clientHeight;
Hoffset1 = img22.offsetHeight;
Woffset1 = img22.offsetWidth;
没什么好讲的,查手册2。
MSDN 在线手册
http://msdn2.microsoft.com/en-us/library/hbxc2t98.aspx