There are known issues with IE and z-index. Which version of IE are you using firstly? Also does this help? It looks related, you may need to get your code up to get this resolved -> http://www.webmasterworld.com/css/3337315.htm
What about changing the zIndex of iFrame to a negative value when the div appears and the changing it to a positive one when the div disappears.
This might help you.
A minimalistic demo page would help to illustrate your problem as IE has several z-index bugs.
A particularly tricky one concerns selectboxes, plugins and (pre IE6) iframes; see http://support.microsoft.com/default.aspx/kb/177378 for a description. In short, these kind of elements always come on top of everything regardless of z-index.
In IE6, you can sometimes use iframes to hack around this, for example by using a jquery plugin.
The second common IE z-index bug concerns z-index "rooting": all children of (IIRC) box-display elements should live in their own z-index scope wherein z-indexes only have meaning relative to one another. IE has a different implementation whereby z-index scope is more global.
why don't you use
#layer
{
visibility:hidden;
}
and then change it to visible and then again hidden, the following function changes css
function changecss(theClass,element,value) {
var cssRules;
var added = false;
for (var S = 0; S < document.styleSheets.length; S++){
if (document.styleSheets[S]['rules']) {
cssRules = 'rules';
} else if (document.styleSheets[S]['cssRules']) {
cssRules = 'cssRules';
} else {
//no rules found... browser unknown
}
for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
if(document.styleSheets[S][cssRules][R].style[element]){
document.styleSheets[S][cssRules][R].style[element] = value;
added=true;
break;
}
}
}
if(!added){
if(document.styleSheets[S].insertRule){
document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
} else if (document.styleSheets[S].addRule) {
document.styleSheets[S].addRule(theClass,element+': '+value+';');
}
}
}
}
call this function like this
javascript:changecss('#layer','visibility','visible');<br>
javascript:changecss('#layer','visibility','hidden');