views:

736

answers:

1

//EDIT My issue was related to something else, I thought the implementation was incorrect but it actually works, thanks for the confirmation.

Looked in jQuery and prototypejs, can't seem to find the way they implement getElementsByTagName on a element (not document.getElementsByTagName).

Here's my test html:

<div id="something" style="margin: 10px 10px 10px 15px; overflow: auto; position: relative; height: 200px;">
    <div style="float: left; width: 180px; font-size: 10px; margin-bottom: 4px;">
        <label for="label_50">
            <img style="vertical-align: middle; margin-right: 3px;" src="http://web1.wow.com/i/i_ask_sm.gif"/&gt;
            <a style="color: rgb(0, 0, 0); text-decoration: underline;" href="http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&amp;t=webpages&amp;url=[URL]&amp;title=[TITLE]" post_link="http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&amp;t=webpages&amp;url=[URL]&amp;title=[TITLE]" rel="external" target="_blank">Ask</a>
        </label>
    </div>
</div>

And my current js:

document.getElementById("something").getElementsByTagName("a");

I'm looking for the correct implementation of this because of course IE doesn't seem to work correctly with it, and I can't use a framework.

+2  A: 
<div id="something" style="margin: 10px 10px 10px 15px; overflow: auto; position: relative; height: 200px;">
 <div style="float: left; width: 180px; font-size: 10px; margin-bottom: 4px;">
  <label for="label_50">
   <img style="vertical-align: middle; margin-right: 3px;" src="http://web1.wow.com/i/i_ask_sm.gif"/&gt;
   <a style="color: rgb(0, 0, 0); text-decoration: underline;" href="http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&amp;t=webpages&amp;url=[URL]&amp;title=[TITLE]" post_link="http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&amp;t=webpages&amp;url=[URL]&amp;title=[TITLE]" rel="external" target="_blank">Ask</a>
  </label>
 </div>
</div>
<pre>
<script type="text/javascript">
var lnks = document.getElementById("something").getElementsByTagName("a");
for (var ii = 0; ii < lnks.length; ++ii) {
 document.writeln(lnks[ii].href);
}
</script>
</pre>

In IE6, IE7 and IE8RC1 this outputs:

http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&amp;t=webpages&amp;url=[URL]&amp;title=[TITLE]

Does your example not actually demonstrate the problem?

Grant Wagner
I just realized the problem is related to something else, will update my question.
Luca Matteis