chrome和safari中的getElementsByTagName问题 [英] getElementsByTagName problem in chrome and safari
本文介绍了chrome和safari中的getElementsByTagName问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用javascript解析Google Maps RSS,并使用以下代码获取点坐标:
point_coords = items.getElementsByTagName('georss:point' )
不幸的是,它在FF中工作,但不适用于Safari和Chrome(在Opera和IE中仍未测试)
XML看起来像:
< item>
< guid isPermaLink =false> guidNo< / guid>
< pubDate> Mon,23 Mar 2009 20:16:41 + 0000< / pubDate>
< title> title text< / title>
< description><![CDATA [text]]>< / description>
< author> UniCreditBulbank< / author>
< georss:point>
42.732342 23.296659
< / georss:point>
< / item>
解决方案
最终解决方案在IE6,7,8,FF ,Opera,Chrome和Safari
point_coords = item.getElementsByTagName('georss:point')[0];
if(!point_coords || point_coords == null){
point_coords = item.getElementsByTagName('point')[0];
}
if(!point_coords || point_coords == null){
point_coords = item.getElementsByTagNameNS('http://www.georss.org/georss','point')[ 0];
}
return point_coords
感谢他们做的所有提示) / p>
I`m parsing a Google Maps RSS with javascript and using the following code to get the point coordinates:
point_coords = items.getElementsByTagName('georss:point')
Unfortunately it works in FF but not in safari and chrome (still not tested in Opera and IE)
The XML looks like:
<item>
<guid isPermaLink="false">guidNo</guid>
<pubDate>Mon, 23 Mar 2009 20:16:41 +0000</pubDate>
<title>title text</title>
<description><![CDATA[text]]></description>
<author>UniCreditBulbank</author>
<georss:point>
42.732342 23.296659
</georss:point>
</item>
解决方案
Final solution working in IE6,7,8, FF, Opera, Chrome and Safari
point_coords = item.getElementsByTagName('georss:point')[0];
if(!point_coords || point_coords == null){
point_coords = item.getElementsByTagName('point')[0];
}
if(!point_coords || point_coords == null){
point_coords = item.getElementsByTagNameNS('http://www.georss.org/georss', 'point')[0];
}
return point_coords
Thanks for all hints they did the job )
这篇关于chrome和safari中的getElementsByTagName问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文