以下代码在IE8下没问题,用IE8兼容视图也没问题,可在IE6下,和IETester所有版本下都有问题问题是:弹出了层,框架没有加载外部网页。另外想在外部网页未加载之前希望能显示:网页加载中……<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>list</title>
<script>
var iss=0;
var ig,wb;
var W=600,H=400;
function A(url){
document.getElementById("container").style.display="none";
  if(iss==0){
var Bind = function(object, fun) {
return function() {
return fun.apply(object, arguments);
}
}

wb = document.createElement("div");
with(wb.style){
position = 'absolute';
wb._resize = Bind(wb, function(){
zIndex = '10000';
width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px";
height =Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px";
position="absolute";
left = '0';
top = '0';
background = '#000000';
filter = 'Alpha(opacity=70)';
opacity = '0.7';
});
wb._resize();
if(document.all){
window.attachEvent("onresize", wb._resize); 
}
else{
window.addEventListener("onresize", wb._resize,false); 
}
}
ig = document.createElement("div");
with(ig.style){
width=W+"px";
height=H+"px";
position = 'absolute';
zIndex = '10001';
left = '50%';
top = '50%';
marginLeft = - (W+10) / 2 + 'px';
marginTop = - (H+10) / 2 + 'px';
border = '1px solid #999999';
padding='4px'
background='#FFFFFF'
}
ig.innerHTML='<iframe src="'+url+'" frameborder="0" scrolling="no" height="'+H+'" width="'+W+'"></iframe>';
}
else{
ig.innerHTML='<iframe src="'+url+'" frameborder="0" scrolling="no" height="'+H+'" width="'+W+'"></iframe>';
    ig.style.display="inline";
    wb.style.display="inline";
}
wb.onclick = function(){bc()}
function bc(){
document.getElementById("container").style.display="";
ig.style.display="none";
    wb.style.display="none";
}
document.body.appendChild(ig);
document.body.appendChild(wb);
iss=1;

}
</script>
</head><body>
<div id="container">
<a href="javascript:;" onclick="A('http://www.baidu.com');">点击我看看11111</a><br><br>
<a href="javascript:;" onclick="A('http://www.google.com');">点击我看看22222</a>
</div>
</body>
</html>

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>list</title>
    <script>
    var iss=0;
    var ig,wb;
    var W=600,H=400;
    function A(url){
        document.getElementById("container").style.display="none";
      if(iss==0){
        var Bind = function(object, fun) {
        return function() {
            return fun.apply(object, arguments);
            }
        }
        
        wb = document.createElement("div");
        with(wb.style){
            position = 'absolute';
            wb._resize = Bind(wb, function(){
            zIndex = '10000';
            width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px";
            height =Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px";
            position="absolute";
            left = '0';
            top = '0';
            background = '#000000';
            filter = 'Alpha(opacity=70)';
            opacity = '0.7';
            });
            wb._resize();
            if(document.all){
                window.attachEvent("onresize", wb._resize); 
            }
            else{
            window.addEventListener("onresize", wb._resize,false); 
            }
        }
        ig = document.createElement("div");
        with(ig.style){
            width=W+"px";
            height=H+"px";
            position = 'absolute';
            zIndex = '10001';
            left = '50%';
            top = '50%';
            marginLeft = - (W+10) / 2 + 'px';
            marginTop = - (H+10) / 2 + 'px';
            border = '1px solid #999999';
            padding='4px'
            background='#FFFFFF'
        }
        ig.innerHTML='<iframe src="" id="ifr_url" frameborder="0" scrolling="no" height="'+H+'" width="'+W+'"></iframe>';
    }
        else{
        ig.innerHTML='<iframe src="" id="ifr_url" frameborder="0" scrolling="no" height="'+H+'" width="'+W+'"></iframe>';
    ig.style.display="inline";
        wb.style.display="inline";
        }
        wb.onclick = function(){bc()}
        function bc(){
            document.getElementById("container").style.display="";
            ig.style.display="none";
               wb.style.display="none";
        }
        document.body.appendChild(ig);
        document.body.appendChild(wb);
        iss=1;
    document.getElementById('ifr_url').src=url;
    }
    </script>
    </head><body>
    <div id="container">
    <a href="javascript:;" onclick="A('http://www.baidu.com');">点击我看看11111</a><br><br>
    <a href="javascript:;" onclick="A('http://www.google.com');">点击我看看22222</a>
    </div>
    </body>
    </html>