简体   繁体   English

jQuery / Javascript在Firefox上不起作用。 为什么?

[英]Jquery/Javascript not working on Firefox. Why?

I just found out that my script is working fine in Chrome, but not in FireFox - and I can't figure out why. 我刚刚发现我的脚本在Chrome中可以正常运行,但在FireFox中却无法正常工作-我不知道为什么。

This is the site in development: www.fireflycovers.com 这是开发中的网站: www.fireflycovers.com

The script should execute when one of the round green buttons is clicked. 单击圆形绿色按钮之一时,脚本应执行。 (scrolls the window to the next container) (将窗口滚动到下一个容器)

The script looks like this at the moment: 此刻脚本如下所示:

$('.scroll').css('display' , 'block');
$('.scroll').on('click', function(e) {
    var container = $(this).parent();

    // Scans if last container in group
    while (document != container[0] && 
           container.find('~.col, ~:has(.col)').length == 0) {

           // If so, search siblings of parent instead
           var container = container.parent(),
               nextdiv = container.nextAll('.col, :has(.col)').first();
    }

    // Back to first .col (when no next .col)
    if (nextdiv.length == 0) {
        nextdiv = $(document).find('.col:first')
    };

    // Animates scrolling to new position
    $('body').animate({scrollTop:nextdiv.offset().top}, 1000);  
        return false;
    });
});

Did you try debugging at all? 您是否尝试过调试? As in, putting console.log statements throughout your method to see what the values of things are at certain times and watching it execute? console.log在整个方法中放置console.log语句以查看特定时间的事物值并观察其执行情况? Anyway, does using this help at all? 无论如何,使用此功能是否有帮助?

$('body,html').animate({scrollTop:nextdiv.offset().top}, 1000);

Verified from Animate scrollTop not working in firefox Animate scrollTop验证无法在Firefox中使用

You need html because firefox behaves differently when it comes to overflow . 您需要html因为在发生overflow时,Firefox的行为有所不同。

暂无
暂无

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

相关问题 JavaScript无法在Firefox中使用。 可能会解析 - JavaScript not working in Firefox. Might be parseInt jQuery .ajax()GET请求无法从Firefox运行。 与Chrome搭配使用 - jQuery .ajax() GET request not working from firefox. Works with Chrome Jquery columnizer插件:在Windows Firefox中快40倍。 为什么? - Jquery columnizer plugin: 40 times faster in Windows Firefox. Why? 在Firefox中未执行javascript。 镀铬还可以 - javascript not being executed in firefox. Ok in chrome 仅适用于chrome的JavaScript脚本,不适用于Firefox。 (用于拖动div的脚本) - JavaScript script that only work on chrome, not working in Firefox. (Script for dragging div) 某些Javascript功能和标记在Chrome中不起作用,但在Mozilla Firefox中却可以正常工作。 帮助我吗? - Some Javascript Function and Tag Not Working In Chrome,but Its Work Good In Mozilla Firefox. Help Me Out Of These? 应该保存暗模式设置的 Javascript 在 Firefox 的子文件夹中不起作用。 如何解决这个问题? - Javascript that is supposed to save darkmode setting, is not working in sub folders in Firefox. How to fix this? JavaScript函数在Opera中工作正常,但在Firefox中根本不工作。 为什么? - JavaScript function works fine in Opera but doesn't work at all in Firefox. Why? 击倒事件; 在Firefox中不工作。 但是,使用Chrome浏览器 - key down event of ; are not working in firefox. But, working in chrome Javascript 按键事件在 Firefox 中不起作用。有什么替代方案? - Javascript keypress event not functioning in Firefox. What is the alternative?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM