frame的机制就是这样。单纯改无法实现解决方法:
在生成菜单的js函数里面,菜单下面再生成一个iframe(z-index在最顶层),它托住菜单的div。就可以了
例如生成菜单的代码为:
document.body.appendChild(alertFram);
document.body.appendChild(shield);
//加个iframe拖住
adjustiFrame();
则iframe的添加代码为:
function adjustiFrame(){ // 如果没有IFrame,则创建之 if (!document.getElementById("ifName")) { var newNode = document.createElement("iFrame"); newNode.setAttribute("id", "ifName"); newNode.setAttribute("src", "javascript:false;"); newNode.setAttribute("scrolling", "no"); newNode.setAttribute("frameborder", "0"); document.body.appendChild(newNode); } iFrameDiv = document.getElementById("ifName"); var div = document.getElementById("alertFram"); // 调整IFrame的位置与div重合,并在div的下一层 try { iFrameDiv.style.position = "absolute"; iFrameDiv.style.width = div.offsetWidth; iFrameDiv.style.height = div.offsetHeight;
iFrameDiv.style.marginLeft = div.style.marginLeft;
iFrameDiv.style.marginTop = div.style.marginTop; iFrameDiv.style.top = div.style.top; iFrameDiv.style.left = div.style.left; iFrameDiv.style.zIndex = div.style.zIndex - 1; //iFrameDiv.style.visibility = div.style.visibility; } catch (e) { }}
在生成菜单的js函数里面,菜单下面再生成一个iframe(z-index在最顶层),它托住菜单的div。就可以了
例如生成菜单的代码为:
document.body.appendChild(alertFram);
document.body.appendChild(shield);
//加个iframe拖住
adjustiFrame();
则iframe的添加代码为:
function adjustiFrame(){ // 如果没有IFrame,则创建之 if (!document.getElementById("ifName")) { var newNode = document.createElement("iFrame"); newNode.setAttribute("id", "ifName"); newNode.setAttribute("src", "javascript:false;"); newNode.setAttribute("scrolling", "no"); newNode.setAttribute("frameborder", "0"); document.body.appendChild(newNode); } iFrameDiv = document.getElementById("ifName"); var div = document.getElementById("alertFram"); // 调整IFrame的位置与div重合,并在div的下一层 try { iFrameDiv.style.position = "absolute"; iFrameDiv.style.width = div.offsetWidth; iFrameDiv.style.height = div.offsetHeight;
iFrameDiv.style.marginLeft = div.style.marginLeft;
iFrameDiv.style.marginTop = div.style.marginTop; iFrameDiv.style.top = div.style.top; iFrameDiv.style.left = div.style.left; iFrameDiv.style.zIndex = div.style.zIndex - 1; //iFrameDiv.style.visibility = div.style.visibility; } catch (e) { }}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货