jQuery在Chrome和Safari中工作,但不能在Firefox或IE中工作
jQuery working in Chrome and Safari, but not Firefox or IE?
我被一些JavaScript/jQuery代码所难倒,这些代码在Webkit浏览器(Chrome和Safari)中完美运行,但在Firefox或IE中根本无法工作,我希望有人可以指出我的错误?
我正在做的是使用jQuery提取GeoRSS提要,然后使用Leaflet在地图上绘制位置点。不知何故,使用火狐或IE时没有绘制点?这是有问题的页面:http://bit.ly/19N0I75
这是代码:
var map = L.mapbox.map('map', 'primitive.geography-class').setView([42, 22], 4);
var wordpressIcon = L.icon({
iconUrl: 'http://www.shifting-sands.com/wp-content/themes/shiftingsands/images/icons/wordpress.png',
iconSize: [18, 18], // size of the icon
shadowSize: [0, 0], // size of the shadow
iconAnchor: [9, 9], // point of the icon which will correspond to marker's location
shadowAnchor: [0, 0], // the same for the shadow
popupAnchor: [0, 0] // point from which the popup should open relative to the iconAnchor
});
jQuery(document).ready(function($){
$.get("http://shifting-sands.com/feed/", function (data) {
var $xml = $(data);
var $i = 0;
$xml.find("item").each(function () {
var $this = $(this),
item = {
title: $this.find("title").text(),
linkurl: $this.find("link").text(),
description: $this.find("description").text(),
pubDate: $this.find("pubDate").text(),
latitude: $this.find("lat").text(),
longitude: $this.find("long").text()
}
lat = item.latitude;
long = item.longitude;
title = item.title;
clickurl = item.linkurl;
//Get the url for the image.
var htmlString = '<h4><a href="' + clickurl + '" target="_blank">' + title + '</a></h4>';
var contentString = '<div id="content">' + htmlString + '</div>';
//Create a new marker position using the Leaflet API.
var rssmarker = L.marker([lat, long], {icon: wordpressIcon}).addTo(map);
//Create a new info window using the Google Maps API
rssmarker.bindPopup(contentString, {closeButton: true});
$i++;
});
});
});
谢谢!
因为 lat 值是命名空间的 (geo:lat),所以你不会从你的find()
中获得任何值。因此错误(,)
,两个空值,用逗号分隔。您必须将查询更改为以下内容:
latitude: $this.find("geo'':lat").text()
双反斜杠转义冒号。
相关文章:
- 为什么这在IE中的工作方式与在Firefox中不同
- JS可以在Chrome中工作,但不能在Firefox中工作
- Facebook登录按钮没有'不能在Firefox上工作
- JS在firefox中无法正常工作
- firefox插件:退出不工作的应用程序观察器
- :focus:一起活跃,不在firefox上工作
- 加载Soundcloud嵌入式播放器OnClick在FireFox中不工作
- javascript()onclick隐藏元素-dos'我不在firefox工作
- 异步加载的SVG过滤器feColorMatrix在Chrome中工作,而不是在Safari或Firefox中
- Iframe加载调整大小在Chrome中工作,但不能在IE或Firefox中工作
- 按钮处于活动状态,焦点无法在Mac FireFox上工作
- HTML5 Canvas undo是'在IE或Firefox中无法正常工作
- javascript代码,用于删除firefox中的空白,但在IE和chrome中无法正常工作
- JavaScript 在 Chrome 中工作,而不是在 Firefox 中
- jQuery代码在Firefox中工作,但在IE中失败
- Javascript加载功能只能在一半的时间内工作(Firefox)
- jQuery点击不工作FireFox -可能是event.preventdefault
- JQUERY .load不能与窗口一起工作.firefox中的位置
- Javascript菜单不工作Firefox
- Jquery只在我重新加载页面时工作-Firefox