Jquery 飄窗

來源:互聯網
上載者:User

標籤:style   blog   http   color   java   os   io   2014   

 1 <script type="text/javascript" src="jquery.js"></script> 2 <script type="text/javascript"> 3 (function($) { 4     $.fn.floatAd = function(options) { 5         var defaults = { 6             imgSrc:"", 7             url:"", 8             openStyle: 1, 9             speed: 3010         };11         var options = $.extend(defaults, options);12         var _target = options.openStyle == 1 ? "target=‘_blank‘": ‘‘;13         var html = "<div id=‘float_ad‘ style=‘position:absolute;left:0px;top:0px;z-index:1000000;cleat:both;‘>";14         html += "  <a href=‘" + options.url + "‘ " + _target + "><img src=‘" + options.imgSrc + "‘ border=‘0‘ class=‘float_ad_img‘/></a>";15         html += "<div id=‘close_f_ad‘ style=‘position:absolute;width:30px;height:16px;top:-18px;right:0px;cursor:pointer;float:right;font-size:14px‘>關閉</div></div>";16         $(‘body‘).append(html);17         function init() {18             var x = 0,19             y = 0;20             var xin = true,21             yin = true;22             var step = 1;23             var delay = 10;24             var obj = $("#float_ad");25             obj.find(‘img.float_ad_img‘).load(function() {26                 var float = function() {27                     var L = T = 0;28                     var OW = obj.width();29                     var OH = obj.height();30                     var DW = $(document).width();31                     var DH = $(document).height();32                     x = x + step * (xin ? 1 : -1);33                     if (x < L) {34                         xin = true;35                         x = L;36                     }37                     if (x > DW - OW - 1) {38                         xin = false;39                         x = DW - OW - 1;40                     }41                     y = y + step * (yin ? 1 : -1);42                     if (y > DH - OH - 10) {43                         yin = false;44                         y = DH - OH - 10;45                     }46                     if (y < T) {47                         yin = true;48                         y = T;49                     }50                     var left = x;51                     var top = y;52                     obj.css({53                         ‘top‘: top,54                         ‘left‘: left55                     })56                 };57                 var itl = setInterval(float, options.speed);58                 $(‘#float_ad‘).mouseover(function() {59                     clearInterval(itl)60                 });61                 $(‘#float_ad‘).mouseout(function() {62                     itl = setInterval(float, options.speed)63                 })64             })65         }66         init();67         $(‘#close_f_ad‘).click(function(){68                     $(‘#float_ad‘).css(‘display‘,‘none‘);69                     clearInterval(itl);70                 });71     }72 })(jQuery);73 74 $(document).ready(function() {75     $(function() {76         $("body").floatAd({77             imgSrc: ‘http://www.customs.gov.cn/Portals/114/images/zxftyg2014010601.jpg‘,78             url: ‘http://www.customs.gov.cn/tabid/66651/Default.aspx‘79         });80     })81 });82 </script>
View Code

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.