jquery.bgiframe-2.1.2.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
  2. * Licensed under the MIT License (LICENSE.txt).
  3. *
  4. * Version 2.1.2
  5. */
  6. (function($){
  7. $.fn.bgiframe = ($.browser.msie && /msie 6\.0/i.test(navigator.userAgent) ? function(s) {
  8. s = $.extend({
  9. top : 'auto', // auto == .currentStyle.borderTopWidth
  10. left : 'auto', // auto == .currentStyle.borderLeftWidth
  11. width : 'auto', // auto == offsetWidth
  12. height : 'auto', // auto == offsetHeight
  13. opacity : true,
  14. src : 'javascript:false;'
  15. }, s);
  16. var html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
  17. 'style="display:block;position:absolute;z-index:-1;'+
  18. (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
  19. 'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
  20. 'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
  21. 'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
  22. 'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
  23. '"/>';
  24. return this.each(function() {
  25. if ( $(this).children('iframe.bgiframe').length === 0 )
  26. this.insertBefore( document.createElement(html), this.firstChild );
  27. });
  28. } : function() { return this; });
  29. // old alias
  30. $.fn.bgIframe = $.fn.bgiframe;
  31. function prop(n) {
  32. return n && n.constructor === Number ? n + 'px' : n;
  33. }
  34. })(jQuery);