Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<style type="text/css">
/*<![CDATA[*/
.pop1 {
position:absolute;z-Index:101;visibility:hidden;width:100px;background-Color:#FFFFCC;
}
.pop2 {
position:absolute;z-Index:101;visibility:hidden;width:100px;background-Color:#FFCC66;
}
/*]]>*/
</style><script type="text/javascript">
/*<![CDATA[*/
var MyAry=[];
MyAry[0]=['some','This is some']
MyAry[1]=['words','This is words','pop2']
function zxcPop(){
this.ary=[];
this.words(document.body);
this.pops=[]
for (var z0=0;z0<this.ary.length;z0++){
for (var z0a=0;z0a<MyAry.length;z0a++){
if (this.ary[z0].firstChild.data.replace(/[\s&#'"\/;:?,.<>\\*%$£€@()]/img,'').toLowerCase()==MyAry[z0a][0]){
this.ary[z0].style.textDecoration='underline';
if (MyAry[z0a][1]){
this.pops[z0a]=[this.ary[z0],zxcES('DIV',{},document.body)];
this.pops[z0a][1].innerHTML=MyAry[z0a][1];
this.pops[z0a][1].className=MyAry[z0a][2]||'pop1';
this.addevt(this.ary[z0],'mouseover','popup',z0a);
this.addevt(this.ary[z0],'mouseout','popup',z0a);
}
}
}
}
}
zxcPop.prototype.popup=function(e,nu){
zxcES(this.pops[nu][1],{visibility:(e.type=='mouseover'?'visible':'hidden'),left:zxcPos(this.pops[nu][0])[0]+'px',top:zxcPos(this.pops[nu][0])[1]-this.pops[nu][1].offsetHeight+'px'});
}
zxcPop.prototype.words=function(n){
var nu=n.childNodes.length,z0,z1,txt,rn,s,nn;
for(z0=0;z0<nu;z0++) {
txt=n.firstChild.data;
rn=n.removeChild(n.firstChild);
if(rn.nodeType==3){
s=txt.split(' ');
for(var nn,z1=0;z1<s.length;z1++) {
nn=document.createElement('A');
nn.className='zxc';
nn.appendChild(document.createTextNode(s[z1]+' '));
n.appendChild(nn);
this.ary.push(nn);
}
}
else {
zxcWords(rn);
n.appendChild(rn);
}
}
}
zxcPop.prototype.addevt=function(o,t,f,p){
var oop=this;
if (o.addEventListener) o.addEventListener(t,function(e){ return oop[f](e,p);}, false);
else if (o.attachEvent) o.attachEvent('on'+t,function(e){ return oop[f](e,p); });
else {
var prev=o['on'+t];
if (prev) o['on'+t]=function(e){ prev(e); oop[f](e,p); };
else o['on'+t]=o[f];
}
}
function zxcPos(obj){
var rtn=[0,0];
while(obj){
rtn[0]+=obj.offsetLeft;
rtn[1]+=obj.offsetTop;
obj=obj.offsetParent;
}
return rtn;
}
function zxcES(ele,style,par,txt){
if (typeof(ele)=='string') ele=document.createElement(ele);
for (key in style) ele.style[key]=style[key];
if (par) par.appendChild(ele);
if (txt) ele.appendChild(document.createTextNode(txt));
return ele;
}
/*]]>*/
</script>
</head>
<body onload="W=new zxcPop();">
Some more Words.
</body>
</html>
Bookmarks