JavaScript ad floating effect code
This example is mainly a Web page floating advertising code, is a small box floating in the Web page. The implementation of this web page floating ads is also very simple, in the Web page through JavaScript to find ID img1 Div, and then through the JS code to achieve the Web page floating ads.
Very simple a div and then call Js.js to control this div
Look at the Js.js code in the floating ad code of the Web.
<script type= "Text/javascript" >
var x=0;
var y=0;
var vx=1;
var vy=1;//
function Move () {
var Pic=document.getelementbyid ("Pic") each time it moves;
X=X+VX;
Y=y+vy;
pic.style.left=x+ "px";
pic.style.top=y+ "px";
If the x+ picture is wider than the width of the window or x<0, the reverse moves if
(x+pic.offsetwidth) >document.body.clientwidth| | x<0) {
VX=-VX};
if ((y+pic.offsetheight) >document.body.clientheight| | y<0) {
vy=-vy};
}
SetInterval ("Move ()");
function shut () {
document.body.removeChild (document.getElementById ("pic"))
}
</script>
See the code in HTML
<body style= "padding:0px;margin:0px;" >
<div id= "pic" style= "Position:absolute" > <input
"button" value = "Close" style= "Position:absolute" onclick= "Shut ()" >
</div>
</body>
The novice asked the great God more guidance
Deephug