JavaScript implementation with closed button on the Web page floating advertising code

Source: Internet
Author: User

  There are many ways to implement a floating picture with off functionality, here's how to use JavaScript, like the number of friends to understand the following

  Code as follows: <html>  <head>  <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">  <title> Web page with close button floating AD code </title>  </head>  <body>  <div id= "img" style= "Position:absolute; left:311; Top:815;visibility:hidden "onmouseover=" clearinterval (interval) "onmouseout=" interval = setinterval (' Changepos () ') , delay) "align=" right >  <a href= "#" target= "_blank" ><img border= "0" src= "Picture path" onload= "return Imgzoom (this,600); "onclick=" Javascript:window.open (THIS.SRC); "style=" cursor:pointer; " /></a>  <span style= "Cursor:hand;color:red;font-weight:bold" onclick= "ClearInterval" (interval); img.style.visibility = ' hidden ' ">X</span>  </div>  <script language=javascript src=ff.js >    </script>  </body>  </html>    ff.js code   code is as follows: var xpos = 20;   var yPos = document.body.clientheight;  var step = 1;  var delay = 30;  var = 0;  var hoffset = 0;  var woffset = 0;  var yon = 0;  var Xon = 0;  var pause = true;  var interval;  img.style.top = ypos;  function Changepos () {  width = document.body.clientwidth;  height = document.body.clientheight;  Hoffset = img.offsetheight;  Woffset = img.offsetwidth;  Img.style.left = xpos + document.body.scrollleft;  img.style.top = YPos + document.b ody.scrolltop;  if (yon) {  YPos = YPos + step; }  else {  yPos = ypos-step; }  If (YPos < 0) {  Yon = 1;  YPos = 0; }  if (YPos >= (height-hoffset)) {  Yon = 0;  YPos = (Height- Hoffset); }  if (xon) {  xpos = xpos + step; }  else {  xpos = xpos-step; }  if (xpos < 0) {  Xon = 1;  xpos = 0; }  if (xpos >= (width-woffset)) {  Xon = 0;  x Pos = (Width-woffSet); } }  function Start () {  img.style.visibility = "visible";  interval = setinterval (' Chan Gepos () ', delay); }  start (); 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.