广告浮动
代码如下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="../jqury/jQury/jquery-1.11.1.min.js"></script>
<script>
var x=50;
var y=60;
var delay=10;
var nx=true,ny=true;
var step=1;
var timer;
function ajax1(){
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("get","js6.html?fname=mike&lname=gate",true);
xmlhttp.send();
}
function move(){
var l=0;
var t=0;
var yx=document.getElementById("apDiv1");
var r=document.documentElement.offsetWidth-document.getElementById("apDiv1").offsetWidth;
var b=document.documentElement.clientHeight-document.getElementById("apDiv1").clientHeight;
yx.style.left=x+"px";
yx.style.top=y+"px";
x=x+step*(nx?1:-1);
if(x<l){nx=true;x=l;}
if(x>r){nx=false;x=r;}
y=y+step*(ny?1:-1);
if(y<t){ny=true;y=t;}
if(y>b){ny=false;y=b;}
timer=setTimeout("move()",delay);
}
function stopTimer(){
clearTimeout(timer);
}
function close1(){
document.getElementById("apDiv1").style.display="none";
}
$(document).ready(function(){
$("#apDiv1",this).hover(function(){
$("#button1",this).fadeIn();
});
$("#apDiv1",this).mouseleave(function(){
$("#button1",this).fadeOut();
});
});
</script>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
left:8px;
top:0px;
width:150px;
height:76px;
z-index:1;
background-color: #FF0000;
}
#button1{
position:absolute;
bottom:0;
right:0;
filter:alpha(opacity=40%);
opacity:0.4;
color:#00F;
display:none;
}
#img1{
width:100%;
height:100%;
z-index:-1;
}
-->
</style>
</head>
<body onload="move()">
<div id="apDiv1" onmouseover="stopTimer()" onmouseout="move()"><img src="../jsImage/2011022516043389.gif" id="img1" /><button onclick="close1()" id="button1">关闭</button></div>
<button onclick="ajax1()">获取数据</button><br />
<div id="myDiv">
Ajax
</div>
</body>
</html>