[color=indigo]
[b]这是小妹写的一段js,整段代码疏漏的地方有不少.
我想用jquery去实现它,不知道该怎么做.希望朋友们帮我一下.[/b][/color]
[color=blue][size=medium]
function af()
{
this.isrd = false;
this.height = 100;
this.width = 100;
this.html = '';
if(self == 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 iframebox = document.createElement('div');
iframebox.id = "ifr";
iframebox.style.height = "100%";
iframebox.style.overflow = "hidden";
document.body.appendChild(iframebox);
var iframe = document.createElement("iframe");
iframe.setAttribute('src', this.surl());
iframe.setAttribute('id','ifr2');
iframe.setAttribute('width','100%');
iframe.setAttribute('height','100%');
iframe.setAttribute('style','position:0;');
iframe.setAttribute('style','right:0;');
iframe.setAttribute('style','bottom:0;');
iframe.setAttribute('style','overflow:hidden;');
iframe.setAttribute('frameborder', '0', 0);
iframe.setAttribute('scrolling', 'no');
document.getElementById('ifr').appendChild(iframe);
}
af.prototype.setwindow = function()
{
if (!this.isrd)
{
return;
}
var tempw = this.width;
var box = document.createElement("div");
box.id = "mpl";
box.style.height = this.height + "px";
if (this.right(tempw, 1) != "%")
{
tempw += "px"
}
box.style.width = tempw;
box.innerHTML = this.html;
box.style.position = "absolute";
box.style.right = "20px";
box.style.bottom = "0";
box.style.float = "right";
document.body.appendChild(box);
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);
//removewrap.style.display = "none";
}
}
//--------------------------
var init = new af();
init.width = "200";
init.height = "20";
init.html = 'testing.........................';
init.setwindow();
window.setInterval("init.AutoIframe()", 200);[/size][/color]
[color=indigo]
[b]这个js的作用简述一下就是,把当前页装入一个动态生成的框架,再在框架之外创建一个div用于显示其他内容.
就js而言也是初学能写出来实属不易,希望大家不要取笑..[/b]
[/color]