最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - IE 7, Javascript transparent div onclick - Stack Overflow

programmeradmin0浏览0评论

Well i have a transparent div or the background is set to transparent :) css:

#lowerLayer
{
    position: fixed;
    top: 0px;
    left: 0px;
    right: 0px;
    bottom: 0px;
    width: 100%;
    height: 100%;
    background-color: Transparent;
    cursor: help;
    z-index: 1;
}

The div is placed right under the tag.. and under there i have a blueprint layout.

jquery(this is run in $(document).ready):

$("#lowerLayer").click(function() {
    $(this).fadeTo("fast", 0, function() {
        $(this).hide(0);
    });
});

My layout works perfect in Opera 10 and i guess it works in Opera 9 to... but IE 7 bugs layers that have lower z-index are acting as they are above the transparent div...

Well i have a transparent div or the background is set to transparent :) css:

#lowerLayer
{
    position: fixed;
    top: 0px;
    left: 0px;
    right: 0px;
    bottom: 0px;
    width: 100%;
    height: 100%;
    background-color: Transparent;
    cursor: help;
    z-index: 1;
}

The div is placed right under the tag.. and under there i have a blueprint layout.

jquery(this is run in $(document).ready):

$("#lowerLayer").click(function() {
    $(this).fadeTo("fast", 0, function() {
        $(this).hide(0);
    });
});

My layout works perfect in Opera 10 and i guess it works in Opera 9 to... but IE 7 bugs layers that have lower z-index are acting as they are above the transparent div...

Share Improve this question asked Jun 8, 2009 at 11:40 PeterPeter 38.6k39 gold badges150 silver badges209 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

I had same problem with IE7 and found easier solution. Instead making your div transparent using css use javascript to set it's opacity.

Following your example:

css style

#lowerLayer {
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background-color: #000;
cursor: help;
z-index: 1;
}

javascript code (e.g. after DOM tree is loaded)

document.getElementById("lowerLayer").style.filter = "alpha(opacity=0)";

A simple solution would be to place the transparent div (#lowerLayer) last in the html (just before the closing </body>.

It's a known issue with some browsers (IE for example)

EDIT: as mentioned in my ment, the blockUI plugin handles everything you may ever need if you want to mask your page with an overlay.

发布评论

评论列表(0)

  1. 暂无评论