解决 Ie 6下 select挡住div的通用函数

参考网上文章 http://hi.baidu.com/suofang/blog/item/72f2f7ed23f2324e78f055c4.html 写的一个函数

 


/**
* 让iframe 显示在 指定的div下面 针对ie6 select挡住div 的bug  采用 iframe来当作div的底

* @param string divId        需要解决的div层
* @param string iframeId    采用的 IFRAME ,如果不指定 自动生成一个
* 2007-11-1 gggxin@hotmail.com
* @version 1.0.0
*/

function  topDiv(divId,iframeId)
{
    
var div_dom = document.getElementById(divId);
    
!iframeId && (iframeId = 'Hide4Ie6Buga');    //默认 iframe 的 id
    var iframe_dom = document.getElementById(iframeId);
    
if(!iframe_dom)    //不存在 自动生成 iframe
    {
        
var tmpIframeDom    = document.createElement("IFRAME");
        tmpIframeDom.id        
= iframeId;
        document.body.appendChild(tmpIframeDom);
        iframe_dom 
= document.getElementById(iframeId);
        iframe_dom.src    
= "about:blank";    //javascript:void(0);  about:blank
        iframe_dom.style.display = "block";//none
        iframe_dom.style.position = "absolute";
        iframe_dom.style.scrolling 
= "no";
        iframe_dom.style.frameBorder 
= 0;
//        iframe_dom.style.backgroundColor = "#ff0000";
//
        iframe_dom.setAttribute("style","position:absolute; top:0px; left:0px; "); //display:none;
    }

    
//使iframe 处于 指定的 div 下面
    iframe_dom.style.width = div_dom.offsetWidth;
    iframe_dom.style.height 
= div_dom.offsetHeight;
    iframe_dom.style.top 
= div_dom.style.top;
    iframe_dom.style.left 
= div_dom.style.left;
    iframe_dom.style.zIndex 
= div_dom.style.zIndex - 1;
//    iframe_dom.style.display = "block";
}
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值