Re: DOM/javascript experienced programmer needed for simple task
| From: | Michael Dransfield | Date: | Tue, 14 Jan 2003 19:01:38 +0000 |
| Subject: | Re: DOM/javascript experienced programmer needed for simple task | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-12423@lists.php.net to get a copy of this message | ||
ele = document.getElementById("YOURDIVNAME");
ancs = ele.getElementsByTagName("a");
for (a=0;a<ancs.length;a++){
document.write("anchor : "+ancs[a].name+"<br>");
}
Think this should do it, but it will return all A tags (not just anchors)
Mike
At 13:34 14/01/2003 -0500, Greg Beaver wrote:
is it possible to get a list of anchors in the div if you know the ID of the DIV? Otherwise, I will have to create an extended class to use the phpedit template. Major pain. Greg "Michael Dransfield" <mike@blueroot.net> wrote in message news:5.1.0.14.0.20030114152212.04ae96b0@212.67.194.181... the anchors of a page are available through document.anchors, getting the div that the anchor is in is difficult to do reliably. I would name the div's similar to the anchors like this <div id="appleDIV"> <a name="appleANCHOR">Apples</a> </div> <div id="pearDIV"> <a name="pearANCHOR">Pears!</a> </div> then with js, just remove the ANCHOR and add DIV to get the layer name... At 11:50 14/01/2003 +0100, Jan Schneider wrote:Zitat von Greg Beaver <greg@chiaraquartet.net>:templatehi, We're using webfx.eae.net's tabpanes for the HTML:frames:phpeditreferencedin phpDocumentor. Currently, if an anchor on an invisible tab isitby clicking an a href="doc.html#anchor" tag, the invisible tab will not display. I don't know anything about DOM manipulation and would lovefromif someone with a bit of knowledge could tell me how to get a list of anchors in a div element cross-browser IE 5.5+ NS 6.0+ DOM-compatible, andfoundthere I'm fine because I can just retrieve the attribute once I'veanchorthe anchors. What I can't figure out is how to get the list, or the(a(and how to tell which div it is in once I've found it). Selecting the tab will be easy, so the only stumbling block is finding which tab the anchorhttp://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core.html#ID-19 38918Dname=) is on.getElementsByTagName() is what you are looking for:It can be called on any object that implements the HTMLElement interface: var myDiv = document.getElementById('myDiv'); var myLinks = myDiv.getElementsByTagname('A'); Jan. -- http://www.horde.org - The Horde Project http://www.ammma.de - discover your knowledge http://www.tip4all.de - Deine private Tippgemeinschaft -- PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php-- PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php