IE6 Select masking pop-up layer solution

Source: Internet
Author: User

Use JS to do div pop-up layer, generally in IE can not mask ActiveX control, at the same time under the IE6 select also can't cover. ActiveX defaults are always displayed at the top level in IE, so it is not possible to change the mask relationship by setting the Z-index property of the style. In the information system software, many occasions because of performance, operation and other reasons, often use ActiveX instead of HTML to complete the function

The code is as follows Copy Code

var sd = XX.style.display;
XX.style.display = "None";
...
Display after closing the pop-up layer
XX.style.display = SD;

The easiest way to think of this is to hide the control's object before the div layer pops up, and then display it after the layer is closed. If it is simple to be a page, but if there are more than one iframe nesting, for other IFRAME also exist control is more troublesome.

After IE6 version there is called Shim solution, the basic idea is this, in the current page dynamically create an IFRAME, its z-index than the current is higher, then this IFRAME will appear at the top, Then will be the pop-up div z-index set than this IFRAME to be high, at this time the pop-up div can cover the ActiveX control, schematic see the following diagram (the actual div is coincident with the IFRAME).

Of course also need to set some necessary properties, the key is to set the SRC attribute of the IFRAME as Javascript:false, and set display to none, transparency is 0.

The code is as follows Copy Code

Popdiv is the pop-up layer, Nowindex is the current Z-index
popdiv.style.zindex=nowindex+1;
Add an iframe to cover the ActiveX
if ($get ("__iframebodycover" + winname) ==null) {
var iframebodycover = document.createelement ("iframe");
Iframebodycover.id = "__iframebodycover" +winname;
IframeBodyCover.style.cssText = "Position:absolute;top:0;left:0;width:" + document.body.clientwidth+ "px"; Height: "+ document.body.clientHeight +" Px;background-color: #000000; Filter:alpha (opacity=0);d isplay:none; ";
IFRAMEBODYCOVER.SRC = "javascript:false;";
Document.body.appendChild (Iframebodycover);
}
The z-index of an IFRAME is lower than that of a div.
$get ("__iframebodycover" + winname). Style.zindex = Nowindex;

Of course at this time under the IE6 naturally also can cover select, the need for friends can refer to.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.