473,504 Members | 13,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where to store a "variable" in a <div>?

All,

I'm currently using an alt attribute in a div tag to store "keywords"
for a function that will show or hide certain div's based on a given
keyword. Is there a better (standard) place to put these keywords?

Code can be seen at http://www.straffin.com/test/DUdyn2.html . This is
just a sample... the real "keywords" (and other information) will be
pulled out of an XML file, not programatically generated.

- Akbar
Jul 20 '05 #1
4 3542
Akbar <me@here.com> writes:
I'm currently using an alt attribute in a div tag to store "keywords"
for a function that will show or hide certain div's based on a given
keyword. Is there a better (standard) place to put these keywords?


That sounds like a job for "class". The class attribute value is a
space-separated list of "class" names, and it is meant to distinguish
equivalent elements based on the author's intentions.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
On 12 Sep 2003 10:56:18 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:
Akbar <me@here.com> writes:
I'm currently using an alt attribute in a div tag to store "keywords"
for a function that will show or hide certain div's based on a given
keyword. Is there a better (standard) place to put these keywords?


That sounds like a job for "class". The class attribute value is a
space-separated list of "class" names, and it is meant to distinguish
equivalent elements based on the author's intentions.

/L


I've used "class" to assign CSS styles before... you also mean to tell
me that you can assign multiple CSS styles with multiple classes?

<style>
.red { color : Red; }
.bold { font-weight : bold; }
</style>
<p class="red bold">Wow!</p>

(I just tried it... it works, in IE6 anyway.) Wow! Thanks!

- Akbar

Jul 20 '05 #3
Akbar <me@here.com> writes:
I've used "class" to assign CSS styles before... you also mean to tell
me that you can assign multiple CSS styles with multiple classes?
In a CSS 1 compliant browser, yes. Older browsers, like Netscape 4,
have no support for CSS 2 (except where it matches CSS 1, and then
it's still bad).
(I just tried it... it works, in IE6 anyway.) Wow! Thanks!


I wasn't sure it would work in IE6, since its CSS 2 support
is also seriously lacking. Glad to see they have it.

It should work in Mozilla and Opera, and probably most other
recent browsers.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
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.
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
919
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
7
3605
by: pamelafluente | last post by:
The precious input given by Laurent, Martin, Benjamin about XMLHttpRequest in Javascript, has made me think that perhaps I could improve what I am currently doing by using Ajax. Let's make it...
4
4007
by: joe | last post by:
Hi, I defined: <div id="abc"> </div> in my .html file, after an Ajax query my weberserver sends: <script language="JavaScript"> alert('Hello World!"); </script>
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.