Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery在Chrome和Safari中工作,而不是Firefox或IE?_Javascript_Jquery_Google Chrome_Firefox_Cross Browser - Fatal编程技术网

Javascript jQuery在Chrome和Safari中工作,而不是Firefox或IE?

Javascript jQuery在Chrome和Safari中工作,而不是Firefox或IE?,javascript,jquery,google-chrome,firefox,cross-browser,Javascript,Jquery,Google Chrome,Firefox,Cross Browser,我写的一些JavaScript/jQuery代码在Webkit浏览器(Chrome和Safari)中运行得很好,但在Firefox或IE中根本不起作用,我很困惑,我希望有人能指出我的错误 我正在做的是使用jQuery拉入一个GeoRSS提要,然后使用传单在地图上绘制位置点。在使用Firefox或IE时,不知何故没有绘制点? 这是有问题的一页: 下面是代码: var map = L.mapbox.map('map', 'primitive.geography-class').setView([42

我写的一些JavaScript/jQuery代码在Webkit浏览器(Chrome和Safari)中运行得很好,但在Firefox或IE中根本不起作用,我很困惑,我希望有人能指出我的错误

我正在做的是使用jQuery拉入一个GeoRSS提要,然后使用传单在地图上绘制位置点。在使用Firefox或IE时,不知何故没有绘制点? 这是有问题的一页:

下面是代码:

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++;
});
});
});
var-map=L.mapbox.map('map','primitive.geography class').setView([42,22],4);
var wordpressIcon=L.icon({
伊克努尔:'http://www.shifting-sands.com/wp-content/themes/shiftingsands/images/icons/wordpress.png',
图标大小:[18,18],//图标的大小
阴影大小:[0,0],//阴影的大小
iconAnchor:[9,9],//将对应于标记位置的图标点
shadowAnchor:[0,0],//阴影的情况相同
popupAnchor:[0,0]//相对于iconAnchor打开弹出窗口的点
});
jQuery(文档).ready(函数($){
$.get(”http://shifting-sands.com/feed/,函数(数据){
var$xml=$(数据);
var$i=0;
$xml.find(“项”)。每个(函数(){
变量$this=$(this),
项目={
title:$this.find(“title”).text(),
linkurl:$this.find(“link”).text(),
description:$this.find(“description”).text(),
pubDate:$this.find(“pubDate”).text(),
纬度:$this.find(“lat”).text(),
经度:$this.find(“long”).text()
}
纬度=项目纬度;
long=item.longitude;
title=item.title;
单击URL=item.linkurl;
//获取图像的url。
var htmlString='';
var contentString=''+htmlString+'';
//使用传单API创建新的标记位置。
var rssmarker=L.marker([lat,long],{icon:wordpressIcon}).addTo(map);
//使用谷歌地图API创建一个新的信息窗口
bindPopup(contentString,{closeButton:true});
$i++;
});
});
});

谢谢

因为lat值是命名空间的(geo:lat),所以您的
find()
没有任何值。因此出现错误
(,)
,两个空值,用逗号分隔。您必须将查询更改为:

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

双反斜杠将冒号转义。

适用于firefox 24-mac“无效的LatLng对象”?“错误:无效的LatLng对象:(,)”在mapbox.js中。作为猜测,我会说在对象文字的最后一个属性后面有一个逗号。@AnthonyGrist我也在想类似的事情,但是为什么它会说无效的LatLng对象,而不是报告更一般的语法错误呢?Javascript对LatLng对象一无所知。我怀疑mapbox.js报告了此错误,并抱怨一些输入数据。感谢您的帮助。然而,令人困惑的是,这在Chrome、Safari和Opera中打破了它。这是地图和你的改变:解决了!jQuery中的一个bug意味着它必须是
纬度:$this.find(“geo\\\:lat,lat”).text()
经度:$this.find(“geo\\:long,long”).text()