IE 7 can't getElementByTagName
My question is, what must i change to run this code in Internet Explorer 7 or higher?
var setItem = 2; // Set item to get information
var container = document.getElementById("rootcontainer");
var imgboxrows = container.getElementByTagName("imgbox");
var imgrows = imgboxrows.length;
var imgitem = imgboxrows.item(setItem).innerHTML;
alert("The Rows are "+imgrows+" and the second item in imgbox is "+imgitem);
<imgbox><a href="imgurl0.php"><img src="img0.gif" border="1"></a></imgbox>
<imgbox><a href="imgurl1.php"><img src="img1.gif" border="1"></a></imgbox>
<imgbox><a href="imgurl2.php"><img src="img2.gif" border="1"></a></imgbox>
<imgbox><a href="imgurl3.php"><img src="img3.gif" border="1"></a></imgbox>
<imgbox><a href="imgurl4.php"><img src="img4.gif" border="1"></a></imgbox>
<imgbox><a href="imgurl5.php"><img src="img5.gif" border="1"></a></imgbox>
In Firefox i don't have any problems only in internet explorer 7 (IE7++)
Thank for your helpings
Last edited by pysio; 05-27-2009 at 12:26 PM.
Well first of all there's no such tag as <imgbox> use a <span> or <div> with an id instead.
Unless that's a custom function, it's spelled incorrectly.
That's not my problem
i make a mistake in the real script there is an "s" in getElementsByTagName.
And also I can work with imgbox because that is the Tag Name and I don't want to give any Tags Id's.
Please give me more results for my question.
The problem seems to be that I.E. won't read the innerHTML of non-standard tags. Perhaps you could use DOM methods to read the childNodes, unless someone knows another way.
Originally Posted by pysio
getElementsByTagName is only suipposed to work with tags that actually exist in HTML. You can't invent your own tag names and expect it to work.
The way that you can do it that will work is to use a class name within the div tags that you want to look for and then write a short getElementsByClassName function for those browsers that don't have one built in that will just extract those tags that have the specified class.
That wasn't the problem mentioned. Getting the list of non-standard tags is no problem, bit only I.E. won't read their innerHTML (or DOM nodes ).
Originally Posted by felgall
I suppose one solution is to parse the innerHTML of the containing div.
You can not mix the languages. If you intend to use custom tags, that means you quit HTML and enter the XML field. In XML DOM there is no innerHTML method, as there are no HTML tags, there are XML tags, which is not the same thing. After all, innerHTML is not a standard DOM method at all.
now i made it with <span><a href . ....
thanks for your help
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)