Akbar <me@here.com> wrote in message news:<em********************************@4ax.com>. ..
Is there a better (standard) place to put these keywords?
No, I do not believe so. In fact, you are using "alt", which does have
a standard usage and might cause side effects.
The beauty of JavaScript is that you can dynamically add properties to
any object, including HTML elements. You are not limited to the
"published" attributes. (I do not believe you should use the published
attributes, in fact, as your purpose does not match any of theirs.)
Here are the lines I changed in your JavaScript in order to get the
same effect (under IE6SP1, you will have to test the other browsers
you support):
1. Move the line [ var re = new RegExp(m, "g"); // Set up the match ]
out of the for-loop. There is no reason to keep recreating the RegExp
object.
2. Change the line [ DOMobjDiv.alt = temptextone + " " + temptexttwo;
] to [ DOMobjDiv.keywords = temptextone + " " + temptexttwo; ]. Here,
you have simply created a new, custom attribute "keywords" for your
DIV element and assigned your keywords to it.
3. Change the line [ var result = kids[i].alt.match(re); // Look for
a match ] to [ var result = kids[i].keywords.match(re); // Look for a
match ]. Here, you are searching the custom keywords attribute, rather
than the alt attribute.
Same effect, less chance for a name clash.