Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.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 event.preventdefault仅在Firefox中不工作_Javascript_Jquery - Fatal编程技术网

Javascript event.preventdefault仅在Firefox中不工作

Javascript event.preventdefault仅在Firefox中不工作,javascript,jquery,Javascript,Jquery,我正在构建一个脚本,用于检查html5本地存储cookie,并在没有cookie集的情况下自动启动一个模式窗口。这是一个语言选择器,一旦选择了一种语言,用户将停留在页面上(EN)或重定向到法语站点(FR) 问题是它在firefox中不起作用。实际上,模式窗口(discover.js)根本不起作用。继续获取event.preventdefault错误 这是我的密码: <script type="text/javascript"> function langCheck(){

我正在构建一个脚本,用于检查html5本地存储cookie,并在没有cookie集的情况下自动启动一个模式窗口。这是一个语言选择器,一旦选择了一种语言,用户将停留在页面上(EN)或重定向到法语站点(FR)

问题是它在firefox中不起作用。实际上,模式窗口(discover.js)根本不起作用。继续获取event.preventdefault错误

这是我的密码:

<script type="text/javascript">
  function langCheck(){
    var LS = localStorage.getItem('lang');
    if (LS == null) {
      $('#popup').click()
    } else if (LS == "FR") {
      alert("This is French")
      /* window.location.replace("http://www.supermarchepa.com/fr/index.html"); */
    }
  }
  function setToEng(){
    localStorage.setItem('lang', 'EN');
    $('#myModal').trigger('reveal:close')
  }
  function setToFr(){
    localStorage.setItem('lang', 'FR')
  }
  window.onload = langCheck;
</script>

函数langCheck(){
var LS=localStorage.getItem('lang');
如果(LS==null){
$(“#弹出窗口”)。单击()
}否则,如果(LS=“FR”){
警惕(“这是法语”)
/*window.location.replace(“http://www.supermarchepa.com/fr/index.html"); */
}
}
函数setToEng(){
setItem('lang','EN');
$('#myModal')。触发器('显示:关闭')
}
函数setToFr(){
setItem('lang','FR')
}
window.onload=langCheck;
模式窗口会自动显示(首次访问时),或者用户可以使用以下方式自行设置语言:

<a href="#" class="big-link" data-reveal-id="myModal" data-animation="fade" data-closeonbackgroundclick="false" data-animationspeed="300" id="popup">Select Language</a>

有人有什么想法吗

提前谢谢

(function ($) { 
    $(document).on("click", 'a[data-reveal-id]', function (e) { 
        event.preventDefault(); 
        var modalLocation = $(this).attr('data-reveal-id'); 
        $('#' + modalLocation).reveal($(this).data()); 
    });
    // Im guessing more is comming here???

无论如何。。查看回调函数(e){中的第一个参数,它在哪里?无论如何,在IE和Chrome中,
事件
对象是全局的,在Firefox中,您必须将其作为参数传递,这很可能是问题所在,但查看代码时,不清楚应该在哪里传递,或者在哪里使用它。抱歉,错误指向插件文件(discover.js)。这是该文件中的一段代码。(函数($){$(文档)。在($)上单击,'a[data reveal id]',函数(e){event.preventDefault();var modalLocation=$(this.attr('data-reveal-id');$('.#'+modalLocation)。显示($(this.data());))});
// change: 
event.preventDefault();
// to:
e.preventDefault();