jquery with close button full screen floating ad instance code

Source: Internet
Author: User

Plug-in Source:

The code is as follows Copy Code

(function ($) {
$.fn.floatad = function (options) {
var defaults = {
IMGSRC: "/20100204193850-483274619.jpg",//Floating picture path
URL: "Http://www.111cn.net",//Picture Click Jump Page
Openstyle:1,//Jump page Open mode 1 Open 0 for new page open for current page
Speed:10//Float Speed unit millisecond
};
var options = $.extend (defaults,options);
var _target = Options.openstyle = = 1? "Target= ' _blank '": ";
var html = "<div id= ' float_ad ' style= ' Position:absolute;left:0px;top:0px;z-index:1000000;cleat:both;" > ";
HTML + + "<a href= '" + Options.imgjumptourl + "'" + _target + "></a> <a href= ' javascript:; ' id= ' close_float_ad ' style= ' ' >x</a> ';
HTML + "</div>";

$ (' body '). Append (HTML);

  function init () {
   var x = 0,y = 0
   var xin = true, Yin = True    var step = 1
   var delay = ten
   var obj=$ ("#float_ad")
   obj.find (' img.float_ad_img '). Load (function () {
    var float = function () {
        var L = T = 0;
     var OW = Obj.width ();//width of current advertisement
     var OH = obj.height ();//High
     var DW = $ (document). width ();//browser window wide
      var DH = $ (document). Height ();

x = x + step * (Xin 1:-1);
if (x < L) {
Xin = true; x = L
}
if (x > Dw-ow-1) {//-1 for IE
Xin = false; x = dw-ow-1
}

y = y + step * (Yin 1:-1);
if (Y > Dh-oh-1) {

Yin = false; y = dh-oh-1;
}
if (Y < T) {
Yin = true; y = T
}

var left = x;
var top = y;

Obj.css ({"Top": Top, "left": left});
}
var itl = setinterval (float,options.speed);
$ (' #float_ad '). MouseOver (function () {clearinterval (ITL)});
$ (' #float_ad '). Mouseout (function () {Itl=setinterval (float, options.speed)})
});
Click Close
$ (' #close_float_ad '). Live (' click ', function () {
$ (' #float_ad '). Hide ();
});
}

Init ();

}; Floatad

}) (JQuery);

The call is very convenient:

  code is as follows copy code

<script Type= "Text/javascript" src= "Http://code.jquery.com/jquery-1.8.2.min.js" ></SCRIPT>
 <script Type= "Text/javascript" src= "Floatad.js" ></SCRIPT>
 <script type= "Text/javascript"
  $ (function () {
   //invoke floating plug-in
   $ ("Body"). Floatad ({
  &NBSP;&NBSP;&NBSP;IMGSRC: ' 20100204193850-483274619.jpg ',
    url: ' Http://www.111cn.net '
   });
  })
 </script>

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.