Connecting Tech Pros Worldwide Forums | Help | Site Map

How to apply a work explain for all document?

Cylix
Guest
 
Posts: n/a
#1: Aug 14 '06
In my site,
There will be some word shold have explaination.
The explaination will be shown in a layer(<div>).

How can I add only a JS file to set all the word in every document?
Is it using regular expression and replace the body.innerHTML with the
word to onclick event?
Any better way?

Thank you.


BinnyVA
Guest
 
Posts: n/a
#2: Aug 14 '06

re: How to apply a work explain for all document?


Hi Cylix,
Quote:
In my site,
There will be some word shold have explaination.
The explaination will be shown in a layer(<div>).
>
How can I add only a JS file to set all the word in every document?
Is it using regular expression and replace the body.innerHTML with the
word to onclick event?
I did not completely understand what you asked, but try this...

<html><head>
<title>Explanations</title>
<style type="text/css">
#explainations dd {
display:none;
}
</style>
<script type="text/javascript">
function init() {
var explainations = document.getElementById('explainations');
var terms = explainations.getElementsByTagName("dt");
for(var i=terms.length-1;i>=0;i--) {
var ele = terms[i];

ele.onclick=function(e) {
if(!e) var e = window.event;
var explaination = this.nextSibling;
if(explaination.style.display != "block")
explaination.style.display="block";
else explaination.style.display = "none";
}
}
}
window.onload=init;
</script>
</head>
<body>
<dl id="explainations">
<dt>Hello</dt><dd>A form of greeting</dd>
<dt>42</dt><dd>The answer to life, the universe and everything</dd>
</dl>
</body></html>

Cylix
Guest
 
Posts: n/a
#3: Aug 17 '06

re: How to apply a work explain for all document?


Thanks for reply,

I mead that I have a number of HTM pages, maybe news acticle,
All of them contains the word "APPA".
I want to have a js. which atttached to all HTM,
so that the js will found out all the term "APPA" and set onMouseOver
event to the term "APPA"

Closed Thread