Tag: firefox

jQuery css(’padding’) – Firefox问题

当你尝试获取元素的padding时,似乎Firefox(至少v19.0.2)有jQuery css()函数的问题。 我使用.css(‘padding-left’)时没有问题,但写一行而不是4行会很好,尤其是像这样的简单特征。 以下是显示我的问题的示例,请比较Chrome / Firefox行为: $(‘#log’).append( ‘padding : ‘+ $(‘#sample’).css(‘padding’)+’\n’+ ‘padding-top : ‘+ $(‘#sample’).css(‘padding-top’)+’\n’+ ‘padding-bottom : ‘+ $(‘#sample’).css(‘padding-bottom’)+’\n’+ ‘padding-left : ‘+ $(‘#sample’).css(‘padding-left’)+’\n’+ ‘padding-right : ‘+ $(‘#sample’).css(‘padding-right’)+’\n’ ); #sample { border: 1px solid black; padding: 8px; margin: 10px; } #log { padding: 8px; margin: 10px; } Lorem ipsum 我错过了什么吗? 或者是否有一种解决方法来检索元素的padding而不调用4个函数? 谢谢。

按钮上的jQuery事件冒泡在Firefox中没有按预期工作

我有一个元素,其中有2个元素。 我为每个span元素都有2个附加的jquery click事件处理程序,所以我可以为每次点击做任何我喜欢的事情。 以下是基本代码的快速浏览: HTML Text1 Text2 使用Javascript $(function() { $(‘button’).bind(‘click’, function() { console.log(‘button clicked’); }); $(‘button > span:eq(0)’).bind(‘click’, function() { console.log(‘text1 span clicked’); }); $(‘button > span:eq(1)’).bind(‘click’, function() { console.log(‘text2 span clicked’); }); }); 这一切在Chrome中运行良好,点击事件以正确的顺序捕获:首先在任何span元素上,然后事件冒泡到父按钮元素。 问题是在Firefox中,click事件不会触发任何span元素,只是按钮事件处理程序将事件记录为触发。 这是一个小提琴,所以你可以看到我的意思: http : //jsfiddle.net/spider/RGL7a/2/ 谢谢

jQuery的$ .ajax URL编码问题

我正在使用jQuery的$ .ajax方法向REST服务发送和检索数据。 我提供给$ .ajax方法的一些URL需要空格和其他特殊字符进行编码。 问题在于Chrome,Safari(Webkit)和Internet Explorer浏览器。 Firefox POST是一个URL,它被编码但其他浏览器POST到一个未编码的URL。 举个例子: $.ajax ({ url: “http://localhost:8080/rest/123/Product Line A/[Product Type B]”, type: “POST”, dataType: “json”, data: { … }, success: function(…){}, error: function(…){} }) Firefox以下列格式发布URL: http://localhost:8080/rest/123/Product%20Line%20A/%5BProduct%20Type%20B%5D Chrome,Safari和IE按以下格式发送url: http://localhost:8080/rest/123/Product Line A/[Product Type B] REST服务接受编码(Firefox)格式 – 有没有一种方法可以使所有浏览器保持一致? 提前致谢!

使用firefox w / firebug,如何在浏览器中编写javascript并使用.js文件对象呢?

使用firefox w / firebug,我可以在浏览器中输入javascript并测试一下吗? 我还可以在html中引用.js文件引用中的函数/对象吗?

使用jQuery将Chrome扩展程序移植到Firefox SDK附加组件

我的Chrome扩展程序在后台页面中使用了jQuery,例如jQuery.extend() , jQuery.ajax() , jQuery.deferred() ,(不是DOM操作的东西,在后台页面中没有意义) 。 将此代码迁移到Firefox SDK附加组件 ,没有后台window对象,jQuery需要工作,所以类似于 var $ = require(‘../3rdparty/jquery.min’)(window); 这是jQuery在类似CommonJS的环境中工作的方式,失败了,jQuery本身抛出一个jQuery requires a window with a documentexceptionjQuery requires a window with a document 。 有没有办法在基于Firefox SDK的插件中使用jQuery? Page Workers似乎很有希望,但我无法掌握底层的window对象。 安迪

406在Firefox中使用Jquery $ .post但在Safari或Chrome中不使用时出现不可接受的错误

我正在使用Jquery(1.3.2)$ .post命令来触发对rails服务器的ajax调用。 该代码在Safari和Google Chrome(Mac)上运行良好,但是当我在Firefox(3.5.7)上尝试时,我得到了一个奇怪的“406 Not Acceptable”错误。 当我查看标题时,Firefox表示它只接受’text / javascript’响应。 并且响应Content-Type是’text / html; 字符集= UTF-8′ 。 在Chrome中,接受的类型是’application / json,text / javascript, / ,text / javascript’,响应Content-Type是’application / json; 字符集= UTF-8′ 。 我试图将rails中的内容类型强制为’text / javascript’ format.json do render :json => @races.to_json, :content_type => ‘text/javascript’ end Chrome中的内容类型确实已更改,但Firefox中的内容类型仍为“text / html”。 这是我用来触发ajax调用的代码。 $.post( “/locator”, params, function(data){…}, “json” ); 我有什么办法可以让它在Firefox中运行吗? 谢谢

@HostListener OnClick for outside click在firefox中不起作用

@HostListener OnClick在firefox中不起作用。 我试过onClick,onclick和onGlobalClick。 他们都使用chrome,但在firefox中没有人。 这是我的代码: constructor(private elRef: ElementRef, private renderer: Renderer2) { } @Output() offClick = new EventEmitter(); @HostListener(‘document:click’, [‘$event.path’]) public onGlobalClick(targetElementPath: Array) { const elementRefInPath = targetElementPath.find(e => e === this.elRef.nativeElement); if (!elementRefInPath) { this.offClick.emit(1); } }

使用xhrFields时的状态代码= 0:{withCredentials:true}在使用Firefox的jQuery $ ajax调用中

我正在使用 xhrFields : { withCredentials: true } 在jQuery $ ajax调用中,以便在我的查询中发送会话cookie。 该调用在我的apache日志上给出了正确的状态代码(401/200取决于是否设置了cookie),但Firefox总是收到状态= 0(即$ .ajax()中的错误)如果我删除了这个xhrFields部分,状态代码没问题(但不发送cookie) 这是我在Firefox中使用xhrFields设置收到的响应对象: {“readyState”:0,”responseText”:””,”status”:0,”statusText”:”error”} 我的Apache配置启用了CORS,并且还允许Access-Control-Allow-Credentials(这里是相应的HTTP头) Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: * 在AJAX调用或webserver配置中是否缺少某些东西? 注意:这在Chrome中运行得非常好

Firefox jQuery表单提交无效

var makeField = function(name, value) { return $(”).attr({ type: ‘hidden’, name: name, value: value }); }; $(‘.login’).on(‘click’, function() { var form = $(”).attr(‘method’, ‘POST’); form.append(makeField(‘n0’, ‘data1’)); form.append(makeField(‘n1’, ‘data2’)); form.append(makeField(‘n2’, ‘data3’)); $(document).append(form); form.submit(); }); 上面的代码在Safari,Chrome和Opera中运行正常,但是firefox忽略了form.submit(); 。 我通过添加console.log(‘…’);测试上面的代码console.log(‘…’); 在提交调用的上方和下方,它执行时没有错误。 我也试过调用$(form).submit(); ,我得到了同样不需要的结果。 有没有人遇到这个,或者有解决方案?

jQuery mousemove性能 – 节流事件?

我们正面临着与mousemove连接的jQuery事件传播性能的问题: 我们有一个屏幕填充canvas,需要跟踪用户是否在其上拖动鼠标,因此我们在该对象上添加了一个鼠标移动侦听器,如下所示: ourCanvas.on(‘mousemove’, function(event) { event.preventDefault(); //our drag code here } }); 此代码工作正常,但我们在一个测试系统上的当前Firefox(24)中遇到了严重的性能问题。 分析器告诉我们,大部分时间花在jQuery.event.dispatch() (我们尝试了当前最新的jQuery 1.8,1.9,1.10和2.0)。 我们通过在这里使用“jQuery.event.fix()”性能优化成功地减少了在dispatch()函数中花费的时间: http : //bitovi.com/blog/2012/04/faster-jquery-event-fix。 html但该测试系统的性能仍远低于我们的预期。 经过一些进一步的测试,我设法将其固定在系统上使用的鼠标上:它使用1000Hz 。 我们将用过的鼠标切换到125Hz并且瞧瞧,性能非常好。 我们的假设是,鼠标上的高Hz率引起了很多mousemove事件,因此我们更改了上面的代码以应用事件限制并且每隔X毫秒只调用事件处理: var lastMove = 0; var eventThrottle = 1; ourCanvas.on(‘mousemove’, function(event) { event.preventDefault(); var now = Date.now(); if (now > lastMove + eventThrottle) { lastMove = now; //our drag code here […]