无意中发现可以用这种方法实现跨frameset的层:
将层appendChild到frameset page的document.documentElement!
实现的浏览器仅限(已测):
FF3,Chrome,Safari,Netscape,Mozilla
测试代码:x.html
<html>
<head></head>
<body>
<script>
var maskTips = function(){
this.mask = null;
this.layer = null;
this.title = null;
this.content = null;
this.cssMask = 'position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;background:#000;-moz-opacity:0.6;opacity:0.6;filter:alpha(opacity=60);z-index:100;border:none;';
this.cssLayer = 'position:absolute;left:30%;top:35%;width:300px;height:150px;background:white;border:5px solid #ddd;z-index:102;padding:0;';
};
maskTips.prototype = {
init:function(){
var xdom = (top.document)?top.document:document;
alert(xdom.documentElement);
var xdoc = xdom.createDocumentFragment();
this.mask = xdom.createElement('div');
this.mask.innerHTML = '<iframe src="about:blank" style="width:100%;height:100%;-moz-opacity:0;opacity:0;filter:alpha(opacity=0);"></iframe>';
this.layer = xdom.createElement('div');
this.layer.innerHTML = '<div style="background:#ddd;border-bottom:5px solid #ddd;text-align:right;overflow:hidden;zoom:1;"><h3 style="float:left;margin:0;padding:0;">title</h3><button style="font-size:12px;">X</button></div><div style="padding:5px;">content</div><div class="tips-bd"></div><div class="tips-ft"></div>';
this.mask.style.cssText = this.cssMask;
this.layer.style.cssText = this.cssLayer;
xdoc.appendChild(this.mask);
xdoc.appendChild(this.layer);
this.title = this.layer.childNodes[0];
this.content = this.layer.childNodes[1];
xdom.documentElement.appendChild(xdoc);
xdom = xdoc = null;
}
};
var x = new maskTips();
x.init();
</script>
</body>
</html>
测试代码:y.html
<html>
<head></head>
<frameset rows="300,*">
<frame src="x.html"></frame>
<frame src="http://www.v-ec.com/dh20156/article.asp?id=204"></frame>
</frameset>
</html>
没有评论:
发表评论