漂动的图片[网页特效]

王朝html/css/js·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<BODY>

<img src="/img/link.gif" width="92" height="34" id="webjx1">

<img src="/img/link1.gif" width="92" height="34" id="webjx2">

<img src="/img/link2.gif" width="92" height="34" id="webjx3">

<img src="/img/200406301.jpg" width="92" height="34" id="webjx4">

<SCRIPT LANGUAGE="JavaScript">

GoGoGo("webjx1");

GoGoGo("webjx3");

GoGoGo("webjx2");

GoGoGo("webjx4");

function GoGoGo(objName)

{

var img=document.getElementById(objName) ;

img.style.position="absolute";

img.style.left=parseInt(window.screen.availWidth*Math.random()) + "px";

img.style.top=parseInt(window.screen.availHeight*Math.random()) + "px";

img.setAttribute("xDir",1);//&para;¨&Ograve;&aring;&iquest;&ordf;&Ecirc;&frac14;x&micro;&Auml;·&frac12;&Iuml;ò

img.setAttribute("yDir",1);//&para;¨&Ograve;&aring;&iquest;&ordf;&Ecirc;&frac14;x&micro;&Auml;·&frac12;&Iuml;ò

window.setInterval("randPosition(" + objName + ")","10","JavaScript");

}

function randPosition(obj)

{

var x=parseInt(obj.style.left);

if(x>=window.screen.availWidth-obj.width-20)

obj.setAttribute("xDir",-1);

if(x<=0)

obj.setAttribute("xDir",1);

x+=parseInt(obj.getAttribute("xDir"));

var y=parseInt(obj.style.top);

if(y>=window.screen.availHeight-obj.height-100)

obj.setAttribute("yDir",-1);

if(y<=0)

obj.setAttribute("yDir",1);

y+=parseInt(obj.getAttribute("yDir"));

obj.style.left=x +"px";

obj.style.top =y +"px";

}

</SCRIPT>

</BODY>

</HTML>

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航