简体   繁体   English

jQuery适用于Chrome和Safari,但不能适用于Firefox或IE?

[英]jQuery working in Chrome and Safari, but not Firefox or IE?

I am rather stumped by some JavaScript/jQuery code I've written working perfectly in Webkit browsers (Chrome and Safari), but not working at all in Firefox or IE and I am hoping someone could point out my error? 我为在Webkit浏览器(Chrome和Safari)中完美编写的一些JavaScript / jQuery代码而感到困惑,但在Firefox或IE中却根本无法工作,我希望有人指出我的错误?

What I'm doing is pulling in a GeoRSS feed with jQuery and then plotting the location points on a map using Leaflet. 我正在做的是使用jQuery引入GeoRSS提要,然后使用Leaflet在地图上绘制位置点。 Somehow the points are not being plotted when using Firefox or IE? 使用Firefox或IE时,为什么不绘制点? Here's the page in question: http://bit.ly/19N0I75 这是有问题的页面: http : //bit.ly/19N0I75

And here's the code: 这是代码:

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++;
});
});
});

Thanks! 谢谢!

Because the lat value is namespaced (geo:lat), you get no value out of your find() . 由于lat值是命名空间(geo:lat),因此您无法从find()获得任何值。 Hence the error (,) , two empty values, separated by a comma. 因此,错误(,)是两个空值,以逗号分隔。 You have to alter your query to this: 您必须将查询更改为此:

latitude: $this.find("geo\\:lat").text()

The double backslash escapes the colon. 双反斜杠可避免冒号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 可以在Chrome中正常工作的JavaScript jQuery代码,而不能在Firefox,Safari,IE中运行 - Simply javascript jQuery code working in Chrome, not Firefox, Safari, IE Javascript / jQuery无法在Firefox,Safari和IE中运行。 精通Opera和Chrome - Javascript/jQuery not working in Firefox, Safari and IE. Fine in Opera and Chrome jQuery ajax函数在Safari中不起作用(Firefox,Chrome,IE可以) - jQuery ajax function not working in Safari (Firefox, Chrome, IE okay) jQuery .css()在IE 6,7,8和Firefox中不起作用,但在Chrome,Safari,Opera中起作用 - jQuery .css() not working in IE 6,7,8 and Firefox, but works in Chrome, Safari, Opera jQuery适用于Firefox,Safari,但不适用于Chrome - jQuery working in Firefox, Safari but not in Chrome jQuery不会在IE中返回div,但是Firefox / Chrome / Safari是吗? - JQuery not returning div in IE, but Firefox/Chrome/Safari is? 代码可在Safari,Firefox和Chrome中运行,但不能在IE(对齐)中运行 - Code working in Safari, Firefox, and Chrome, but not in IE (Alignment) 为什么在Firefox,Chrome或Safari上却不能在IE上运行呢? - Why is this not working on Firefox, Chrome or Safari but on IE? 媒体查询无法在Safari中工作,但在IE,Firefox和Chrome中 - Media queries not working in Safari but in IE, Firefox and Chrome 我的Jquery脚本在IE / Safari / Firefox中不起作用 - My Jquery Script is not working in IE / Safari / Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM