How to apply a work explain for all document?

C

Cylix

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.
 
B

BinnyVA

Hi Cylix,
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;

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>
 
C

Cylix

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top