Custom tags handled differently when using getElementsByTagName in IE / FF

Insivyinquise

New Member
I have the following page:\[code\]<html><head> <title>Test</title> <script type="text/javascript"> function BuildTree() { var total = 0; var pages = document.getElementsByTagName('custom:page'); var questions = pages[0].getElementsByTagName('custom:question'); for (var i = 0; i < questions.length; ++i) { var question = questions; var val = question.getAttribute('value') total += val; } alert("Total: " + total); }; </script></head><body> <custom:pages> <custom:page> <custom:question value="http://stackoverflow.com/questions/10516202/1">aaa</custom:question> <custom:question value="http://stackoverflow.com/questions/10516202/2">bbb</custom:question> <custom:question value="http://stackoverflow.com/questions/10516202/3">ccc</custom:question> </custom:page> <custom:page> <custom:question value="http://stackoverflow.com/questions/10516202/1">aaa</custom:question> <custom:question value="http://stackoverflow.com/questions/10516202/2">bbb</custom:question> <custom:question value="http://stackoverflow.com/questions/10516202/3">ccc</custom:question> </custom:page> </custom:pages> <input id="btnTest" type="button" value="http://stackoverflow.com/questions/10516202/Test" onclick="BuildTree();" /></body></html>\[/code\]When I click the Test button in IE the result is 0, when I click it in FF the result is 0123.How can I get the same result in both browsers? i.e. '0123'.Note that I've trimmed this down to as simple an example as possible. I cannot use jquery or any third party libraries, I need a pure Javasscript solution. I also cannot change the custom: tags.Thanks
 
Back
Top