Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

edited so it also works in newer IE to solve object z-index issue #7

Closed
wants to merge 1 commit into from

3 participants

@ckozl

edited so it also works in newer IE as the iframe trick solves the object overlay
z-index issue, iframes are also included because you can't succesfully probe their
content to test for objects (cross domain issue) think embedded youtube video (iframe
with an object inside)... take it or leave it, useful for my purposes tested ie7-9 -ck

@ckozl ckozl edited so it also works in newer IE as the iframe trick solves the ob…
…ject overlay

z-index issue, iframes are also included because you can't succesfully probe their 
content to test for objects (cross domain issue) think embedded youtube video (iframe 
with an object inside)... take it or leave it, useful for my purposes tested ie7-9 -ck
c8ebdc3
@logankd

This fixes my issue with the Silverlight objects. It would be great if this could get into the master.

@brandonaaron

This is now resolved in 3.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 16, 2012
  1. @ckozl

    edited so it also works in newer IE as the iframe trick solves the ob…

    ckozl authored
    …ject overlay
    
    z-index issue, iframes are also included because you can't succesfully probe their 
    content to test for objects (cross domain issue) think embedded youtube video (iframe 
    with an object inside)... take it or leave it, useful for my purposes tested ie7-9 -ck
This page is out of date. Refresh to see the latest.
Showing with 38 additions and 32 deletions.
  1. +38 −32 jquery.bgiframe.js
View
70 jquery.bgiframe.js
@@ -1,39 +1,45 @@
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
- * Licensed under the MIT License (LICENSE.txt).
- *
- * Version 2.1.3-pre
- */
+* Licensed under the MIT License (LICENSE.txt).
+*
+* Version 2.1.3-pre
+*/
-(function($){
+(function($) {
+ var isie6 = /msie 6\.0/i;
+ $.fn.bgiframe = ($.browser.msie ? function(s) {
-$.fn.bgiframe = ($.browser.msie && /msie 6\.0/i.test(navigator.userAgent) ? function(s) {
- s = $.extend({
- top : 'auto', // auto == .currentStyle.borderTopWidth
- left : 'auto', // auto == .currentStyle.borderLeftWidth
- width : 'auto', // auto == offsetWidth
- height : 'auto', // auto == offsetHeight
- opacity : true,
- src : 'javascript:false;'
- }, s);
- var html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
- 'style="display:block;position:absolute;z-index:-1;'+
- (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
- 'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
- 'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
- 'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
- 'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
- '"/>';
- return this.each(function() {
- if ( $(this).children('iframe.bgiframe').length === 0 )
- this.insertBefore( document.createElement(html), this.firstChild );
- });
-} : function() { return this; });
+ if (!isie6.test(navigator.userAgent) && !$('iframe,object').length) {
+ return this;
+ }
+
+ s = $.extend({
+ top: 'auto', // auto == .currentStyle.borderTopWidth
+ left: 'auto', // auto == .currentStyle.borderLeftWidth
+ width: 'auto', // auto == offsetWidth
+ height: 'auto', // auto == offsetHeight
+ opacity: true,
+ src: 'javascript:false;'
+ }, s);
+ var html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' +
+ 'style="display:block;position:absolute;z-index:-1;' +
+ (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '') +
+ 'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : prop(s.top)) + ';' +
+ 'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : prop(s.left)) + ';' +
+ 'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : prop(s.width)) + ';' +
+ 'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' +
+ '"></iframe>';
+ return this.each(function() {
+ if ($(this).children('iframe.bgiframe').length === 0) {
+ this.insertBefore($(html)[0], this.firstChild);
+ }
+ });
+ } : function() { return this; });
-// old alias
-$.fn.bgIframe = $.fn.bgiframe;
+ // old alias
+ $.fn.bgIframe = $.fn.bgiframe;
-function prop(n) {
- return n && n.constructor === Number ? n + 'px' : n;
-}
+ function prop(n) {
+ return n && n.constructor === Number ? n + 'px' : n;
+ }
})(jQuery);
Something went wrong with that request. Please try again.