Closed Thread Icon

Topic awaiting preservation: A HTML tag (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8269" title="Pages that link to Topic awaiting preservation: A HTML tag (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: A HTML tag <span class="small">(Page 1 of 1)</span>\

 
bianca
Obsessive-Compulsive (I) Inmate

From:
Insane since: Aug 2002

posted posted 08-21-2002 09:53

How do you refer to the A tag in javascript? What I mean to say is that if a textbox is referred to as document.form_name.textbox_name, how do i do this with the <A> html tag? Can i use document.form_name.a_name? I'd like to check if the focus of my cursor is on that tag... How can i do this? Thankss......

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 08-21-2002 11:41

Hmm, try this:

<a href="file.htm" onfocus="gFocused='tag3'">I am tag3</a>


whenever you want to know who got the focus just read the global javascript variable gFocused and determine its value.

as for referring it from JavaScript, you have to give it an ID like:
<a id="tag3">
then do: ref=document.getElementById("tag3")

there is also array like: document.links array and document.anchors array, but i never tried them.


Elias

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 08-21-2002 16:33

Anchor can be accessed this way also

document.getElementsByTagName("a")[3] //The 4th anchor

_________________
http://hzr.dzygn.com

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-21-2002 17:39

Or

<a href="..." id="importantAnchorTag"></a>

with

document.getElementById('importantAnchorTag')

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 08-21-2002 19:20

You can also access all links through document.links array...


bianca
Obsessive-Compulsive (I) Inmate

From:
Insane since: Aug 2002

posted posted 08-22-2002 03:14

How do I state,
if (focus is on the anchor tag) {
do this
}
in javascript?

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 08-22-2002 13:07

(took this post away, it was probably wrong anyway)

[This message has been edited by HZR (edited 08-22-2002).]

meccaman
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2002

posted posted 08-22-2002 22:11

I don't know of a function or anything in JavaScript (I'm still learning), but there's always more than one way to skin a cat.
On the onfocus event for each element you want to know about, assign to a global var the element's id, then when you want to check for focus, just loop through the elements comparing the ids with the global var.


« BackwardsOnwards »

Show Forum Drop Down Menu