Javascript 实现点击跳到页头
代码
function popTopTip(obj,img){
var objDiv = document.createElement("div");
objDiv.id = "DivPopTip";
objDiv.style.cssText = "position:absolute; left:0px; top:0px; border:solid 1px #FBD38D; width:41px; height:20px; z-index:10;";
objDiv.style.left = (document.documentElement.clientWidth + document.documentElement.scrollLeft - 45).toString() + "px";
objDiv.style.top = (document.documentElement.clientHeight/2 + document.documentElement.scrollTop).toString() + "px";
objDiv.onclick = function(){document.documentElement.scrollTop=0;};
var objIframe = document.createElement("iframe");
objIframe.style.cssText = "position: absolute;width:100%; z-index:-1; border:0; height:100%; top: 0;left: 0; overflow:hidden";
var objC = document.createElement("div");
objC.id = "DivPopDivC";
objC.style.cursor="pointer";
var objImg = document.createElement("img");
objImg.src = img;
objImg.style.border = "0px";
objC.appendChild(objImg);
objDiv.appendChild(objIframe);
objDiv.appendChild(objC);
if(document.getElementById("DivPopTip")!=null)
{
obj.replaceChild(objDiv,document.getElementById("DivPopTip"));
}
else
{
obj.appendChild(objDiv);
}
}
var objDiv = document.createElement("div");
objDiv.id = "DivPopTip";
objDiv.style.cssText = "position:absolute; left:0px; top:0px; border:solid 1px #FBD38D; width:41px; height:20px; z-index:10;";
objDiv.style.left = (document.documentElement.clientWidth + document.documentElement.scrollLeft - 45).toString() + "px";
objDiv.style.top = (document.documentElement.clientHeight/2 + document.documentElement.scrollTop).toString() + "px";
objDiv.onclick = function(){document.documentElement.scrollTop=0;};
var objIframe = document.createElement("iframe");
objIframe.style.cssText = "position: absolute;width:100%; z-index:-1; border:0; height:100%; top: 0;left: 0; overflow:hidden";
var objC = document.createElement("div");
objC.id = "DivPopDivC";
objC.style.cursor="pointer";
var objImg = document.createElement("img");
objImg.src = img;
objImg.style.border = "0px";
objC.appendChild(objImg);
objDiv.appendChild(objIframe);
objDiv.appendChild(objC);
if(document.getElementById("DivPopTip")!=null)
{
obj.replaceChild(objDiv,document.getElementById("DivPopTip"));
}
else
{
obj.appendChild(objDiv);
}
}
继续追寻。。。。。。