我有以下代码,手头的问题是webkit浏览器,javascript行:
var eventGeoLat = $(this).find('geo\\:lat').text();
var eventGeoLong = $(this).find('geo\\:long').text();
仅在Firefox上正常工作,但在任何webkit浏览器上都没有:
$(data).find('event').each(function(){
/*
Parse the XML and for each event node get:
city
latitude and longitude of the event (to specify google maps marker location)
start date
venue name
last.fm website url
last.fm event image
*/
var eventCity = $(this).find('city').text();
var eventGeoLat = $(this).find('geo\\:lat').text();
var eventGeoLong = $(this).find('geo\\:long').text();
var eventDate = $(this).find('startDate').text();
var eventVenueName = $(this).find('venue').find('name').text();
// This will return two URLs; we only want the second one for the event:
var eventUrl = $(this).find('url').eq(1).text();
// This will return two image URLs; we only want the first one:
var eventImage = $(this).find('image[size="large"]').eq(0).text();
alert('eventCity = ' + eventCity + '\n eventGeoLat = ' + eventGeoLat + '\n eventGeoLong = ' + eventGeoLong + '\n eventDate = ' + eventDate + '\n eventVenueName = ' + eventVenueName);
正确警告Firefox:
eventCity = Manchester
eventGeoLat = 35.482577
eventGeoLong = -86.087875
eventDate = Thu, 07 Jun 2012 01:50:01
eventVenueName = Great Stage Park
但在Chrome上提醒我:
eventCity = Manchester
eventGeoLat =
eventGeoLong =
eventDate = Thu, 07 Jun 2012 01:50:01
eventVenueName = Great Stage Park
大约一年前在jQuery.com上开了一张关于在webkit broswers上找不到正确转义的元字符的票,但这似乎已经解决了,我对这里发生的事情感到茫然。我试过var eventGeoLat = $(this).find('geo\:lat').text();
和var eventGeoLat = $(this).find('geo:lat').text();
只是为了看看jQuery是否会选择不同的东西,但无济于事。