Have you ever experienced the select form element z-index issue in Internet Explorer 6? Most likely you have if you've implemented some sort of drop down menu navigation that shows up over a select form element.
The background iframe (bgiframe) plugin provides a very small, quick and easy way to fix that problem so you don't have to worry about it. No matter the size, borders or position the bgiframe plugin can fix it.
The bgiframe plugin should be used when you are trying to show elements above a select form control in Internet Explorer 6.
The usage is simple. Just call bgiframe
on a jQuery collection of elements.
$('.fix-z-index').bgiframe();
The plugin tries its best to handle most situations but sometimes some configuration is necessary. For example if your borders are defined in a unit other than pixels, you will need to manually set the top
and left
properties to the negative width of the border. Here are the options/settings available to configure the output.
top
The iframe must be offset to the top by the width of the top border. This should be a negative number representing the border-top-width. If a number is is used here, pixels will be assumed. Otherwise, be sure to specify a unit. An expression could also be used. By default the value is "auto" which will use an expression to get the border-top-width if it is in pixels.
$('.fix-z-index').bgiframe({ top: '-1em' });
left
The iframe must be offset to the left by the width of the left border. This should be a negative number representing the border-left-width. If a number is used here, pixels will be assumed. Otherwise, be sure to specify a unit. An expression could also be used. By default the value is "auto" which will use an expression to get the border-left-width if it is in pixels.
$('.fix-z-index').bgiframe({ left: '-1em' });
width
This is the width of the iframe. If a number is used here, pixels will be assume. Otherwise, be sure to specify a unit. An expression could also be used. By default the value is "auto" which will use an expression to get the offsetWidth.
$('.fix-z-index').bgiframe({ width: 100 });
height
This is the height of the iframe. If a number is used here, pixels will be assume. Otherwise, be sure to specify a unit. An expression could also be used. By default the value is "auto" which will use an expression to get the offsetHeight.
$('.fix-z-index').bgiframe({ height: 100 });
opacity
This is a boolean representing whether or not to use opacity. If set to true, the opacity of 0 is applied. If set to false, the opacity filter is not applied. Default: true.
$('.fix-z-index').bgiframe({ opacity: false });
src
This setting is provided so that one could change the src of the iframe to whatever they need. Default: "javascript:false;"
$('.fix-z-index').bgiframe({ src: '#' });
The bgiframe plugin works by prepending an iframe to the element. The iframe is given a class of bgiframe and positioned below all the other children of the element. In the default configuration it automatically adjusts to the width and height of the element (including the borders) and the opacity is set to 0. The element needs to have position (relative or absolute) and should have a background (color or image).
Check out the test page to see the plugin in action.
Feel free to make any suggestions, bug reports or add any patches via the project page.
The bgiframe plugin is authored by Brandon Aaron (http://brandonaaron.net/)