<iframe src="javascript:false" style="position:absolute;visibility:inherit; top:45px; left:16px; width:200px;  height:70px;z-index:-1; filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';"></iframe>
在我们的div中加了这句话,浮动图片有80%的部分可以显示在select之上了。
经过一番调试,深深感慨,如果浮动广告是矩形那该多好啊~~~~~~~~
最后仍没解决问题,看看时间,已经三点半了。明天还有些事,今天不能把自己弄的太累呀~~~~
问题虽没解决,但上网查了不少好方法。
网上答案挺多的,但大多数都是重复的。也不知是谁抄谁的。
于是我也抄些。嘿嘿!

网上方法无数,记了两种印象深刻的方法。
DIV遮盖select
1、找个后台,后台硬自己就跟着强了
2、背后阴别人,让别人弱了,就显得自己强了。



1.iframe来当作div的底
<html>
<head>
<script>
function DivSetVisible(state)
{
var DivRef = document.getElementById('PopupDiv');
var IfrRef = document.getElementById('DivShim');
if(state)
{
DivRef.style.display = "block";
IfrRef.style.width = DivRef.offsetWidth;
IfrRef.style.height = DivRef.offsetHeight;
IfrRef.style.top = DivRef.style.top;
IfrRef.style.left = DivRef.style.left;
IfrRef.style.zIndex = DivRef.style.zIndex - 1;
IfrRef.style.display = "block";
}
else
{
DivRef.style.display = "none";
IfrRef.style.display = "none";
}
}
</script>
</head>
<body>
<form>
<select>
<option>A Select Box is Born ....</option>
</select>
</form>
<div id="PopupDiv" style="position:absolute; top:25px; left:50px; padding:4px; display:none; background-color:#000000; color:#ffffff; z-index:100">
.... and a DIV can cover it up<br/>through the help of an IFRAME.
</div>
<iframe id="DivShim" src="javascript:false;" scrolling="no" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;">
</iframe>
<br/>
<br/>
<a href="#" onclick="DivSetVisible(true)">Click to show DIV.</a>
<br/>
<br/>
<a href="#" onclick="DivSetVisible(false)">Click to hide DIV.</a>
</body>
</html>

2.隐藏下拉框

<script>
var HideElementTemp = new Array();
//点击菜单时,调用此的函数,菜单对象
function cal_hideElementAll(obj){
            cal_HideElement("IMG",obj);
            cal_HideElement("SELECT",obj);
            cal_HideElement("OBJECT",obj);
            cal_HideElement("IFRAME",obj);
}
function cal_HideElement(strElementTagName,obj){
try{
        var showDivElement = obj;
        var calendarDiv = obj;
        var intDivLeft = cal_GetOffsetLeft(showDivElement);
        var intDivTop = cal_GetOffsetTop(showDivElement);//+showDivElement.offsetHeight;
        //HideElementTemp=new Array()
        for(i=0;i<window.document.all.tags(strElementTagName).length; i++){
var objTemp = window.document.all.tags(strElementTagName)[i];
if(!objTemp||!objTemp.offsetParent)
         continue;
var intObjLeft=cal_GetOffsetLeft(objTemp);
var intObjTop=cal_GetOffsetTop(objTemp);
if(((intObjLeft+objTemp.clientWidth)>intDivLeft)&&
        (intObjLeft<intDivLeft+calendarDiv.style.posWidth)&&
        (intObjTop+objTemp.clientHeight>intDivTop)&&
        (intObjTop<intDivTop+calendarDiv.style.posHeight)){
         //var intTempIndex=HideElementTemp.length;//已经有的长度
      //save elementTagName is stutas
         //HideElementTemp[intTempIndex]=new Array(objTemp,objTemp.style.visibility);
         HideElementTemp[HideElementTemp.length]=objTemp
         objTemp.style.visibility="hidden";
            }
        }
}catch(e){alert(e.message)
}
}

function cal_ShowElement(){
        var i;
        for(i=0;i<HideElementTemp.length; i++){
var objTemp = HideElementTemp[i]
if(!objTemp||!objTemp.offsetParent)
         continue;
objTemp.style.visibility=''
        }
        HideElementTemp=new Array();
}
function cal_GetOffsetLeft(src){
        var set=0;
        if(src && src.name!="divMain"){
            if (src.offsetParent){
               set+=src.offsetLeft+cal_GetOffsetLeft(src.offsetParent);
}
if(src.tagName.toUpperCase()!="BODY"){
         var x=parseInt(src.scrollLeft,10);
         if(!isNaN(x))
                set-=x;
}
        }
        return set;
}

function cal_GetOffsetTop(src){
        var set=0;
        if(src && src.name!="divMain"){
            if (src.offsetParent){
                set+=src.offsetTop+cal_GetOffsetTop(src.offsetParent);
       }
if(src.tagName.toUpperCase()!="BODY"){
         var y=parseInt(src.scrollTop,10);
         if(!isNaN(y))
      set-=y;
}
        }
        return set;
}

</script>
<select></select>
<select></select>
<div style="position:absolute;left:0;top:0;width:100;height:100;background-color:red" onclick="cal_hideElementAll(this)">
点击让select隐藏
</div>
<br><br><br><br><br><br>
<input type="button" value="点击让select显示" onclick="cal_ShowElement()">



posted on 2007-12-01 03:44  超少  阅读(1226)  评论(2编辑  收藏  举报