*只是研究 与工作无关
function af(){
this.isrd=false;
this.height=100;
this.width=100;
this.html='';
if(window.self==window.top){
this.isrd=true;
this.cpage();
this.CreatIfr();
}
}
af.prototype.right=function(str,n){
return str.substr(str.length-n,str.length);
};
af.prototype.Dbody=function(){
var bHeight=document.body.clientHeight;
var dHeight=document.documentElement.clientHeight;
var isXhtml=(dHeight<=bHeight&&dHeight!==0)?true:false;
var sDbody=isXhtml?document.documentElement:document.body;
return sDbody;
};
af.prototype.surl=function(){
var nowurl=location.href;
nowurl+=(location.search)?"&":"?";
nowurl+="iris";
return nowurl;
};
af.prototype.cpage=function(){
this.Dbody().style.overflow="hidden";
document.body.innerhtml="";
};
af.prototype.CreatIfr=function(){
var iriscontent1=document.createElement("div");
iriscontent1.id="ifr";
iriscontent1.style.height="100%";
iriscontent1.style.overflow="hidden";
document.body.appendChild(iriscontent1);
var iriscontent=document.createElement("iframe");
iriscontent.src=this.surl();
iriscontent.id="ifr2";
iriscontent.name="ifr2";
iriscontent.width="100%";
iriscontent.height="100%";
iriscontent.style.position="absolute";
iriscontent.style.right="0";
iriscontent.style.bottom="0";
iriscontent.style.overflow="hidden";
iriscontent.setAttribute("frameborder","0",0);
iriscontent.setAttribute("scrolling","no");
document.getElementById("ifr").appendChild(iriscontent);
};
af.prototype.setwindow=function(){
if(!this.isrd){
return ;
}
var tempw=this.width;
var audiocontent=document.createElement("div");
audiocontent.id="mpl";
audiocontent.style.height=this.height+"px";
if(this.right(tempw,1)!="%"){
tempw+="px";
}
audiocontent.style.width=tempw;
audiocontent.innerHTML=this.html;
audiocontent.style.position="absolute";
audiocontent.style.right="20px";
audiocontent.style.bottom="0";
document.body.appendChild(audiocontent);
this.settop(this.height);
};
af.prototype.settop=function(sh){
if(!this.isrd){
return ;
}
};
af.prototype.AutoIframe=function(){
if(!this.isrd){
return ;
}
var removewrap=document.getElementById("iris");
if(removewrap!==null){
removewrap.parentNode.removeChild(removewrap);
}
};
/////////////
var init = new af();
init.html = '123';
init.setwindow();
window.setInterval("init.AutoIframe()", 200);
function af(){
this.isrd=false;
this.height=100;
this.width=100;
this.html='';
if(window.self==window.top){
this.isrd=true;
this.cpage();
this.CreatIfr();
}
}
af.prototype.right=function(str,n){
return str.substr(str.length-n,str.length);
};
af.prototype.Dbody=function(){
var bHeight=document.body.clientHeight;
var dHeight=document.documentElement.clientHeight;
var isXhtml=(dHeight<=bHeight&&dHeight!==0)?true:false;
var sDbody=isXhtml?document.documentElement:document.body;
return sDbody;
};
af.prototype.surl=function(){
var nowurl=location.href;
nowurl+=(location.search)?"&":"?";
nowurl+="iris";
return nowurl;
};
af.prototype.cpage=function(){
this.Dbody().style.overflow="hidden";
document.body.innerhtml="";
};
af.prototype.CreatIfr=function(){
var iriscontent1=document.createElement("div");
iriscontent1.id="ifr";
iriscontent1.style.height="100%";
iriscontent1.style.overflow="hidden";
document.body.appendChild(iriscontent1);
var iriscontent=document.createElement("iframe");
iriscontent.src=this.surl();
iriscontent.id="ifr2";
iriscontent.name="ifr2";
iriscontent.width="100%";
iriscontent.height="100%";
iriscontent.style.position="absolute";
iriscontent.style.right="0";
iriscontent.style.bottom="0";
iriscontent.style.overflow="hidden";
iriscontent.setAttribute("frameborder","0",0);
iriscontent.setAttribute("scrolling","no");
document.getElementById("ifr").appendChild(iriscontent);
};
af.prototype.setwindow=function(){
if(!this.isrd){
return ;
}
var tempw=this.width;
var audiocontent=document.createElement("div");
audiocontent.id="mpl";
audiocontent.style.height=this.height+"px";
if(this.right(tempw,1)!="%"){
tempw+="px";
}
audiocontent.style.width=tempw;
audiocontent.innerHTML=this.html;
audiocontent.style.position="absolute";
audiocontent.style.right="20px";
audiocontent.style.bottom="0";
document.body.appendChild(audiocontent);
this.settop(this.height);
};
af.prototype.settop=function(sh){
if(!this.isrd){
return ;
}
};
af.prototype.AutoIframe=function(){
if(!this.isrd){
return ;
}
var removewrap=document.getElementById("iris");
if(removewrap!==null){
removewrap.parentNode.removeChild(removewrap);
}
};
/////////////
var init = new af();
init.html = '123';
init.setwindow();
window.setInterval("init.AutoIframe()", 200);
这段代码作用是
将当前页装入一个动态生成的iframe
再在这个iframe之外创建一个层 用于定义其他内容
并将原文档中父节点 #iris删除
文档初始结构
<body>
<div id='iris'>
...............
</div>
</body>
应用脚本后的结构 因该是这样
<body>
<div id='ifr'>
<iframe id='ifr2'>
<body>
<div id='iris'>
...............
</div>
</body>
</iframe>
</div>
</body>
从最初构思 到写成 一个补丁+一个补丁这样七拼八凑 还是功底太薄了 不能一气呵成
朋友们能不能够帮我重构一下
|