Firefox doesn't fire $(document).ready(function() {

前端 未结 5 1574
粉色の甜心
粉色の甜心 2021-01-13 07:45

I have a page that uses the jquery function:

$(document).ready(function() {

and I have put an alert in there, and tried everything. It does

相关标签:
5条回答
  • 2021-01-13 08:19

    I had a similar problem and in my case, invoking an old jQuery Address .js file was the problem. For some reason, Edge, Chrome, and Opera were able to ignore maybe that old version of jQuery Address while keeping jQuery/JavaScript to work normally. But Mozilla Firefox did not behave in the same way, and jQuery/JavaScript was not working at all in Mozilla Firefox. In my case the solution was simply to comment out jQuery Address for now and I will need to upgrade it later on. I was surprised that Mozilla Firefox was rigid about it and all other browsers were flexible to allow the jQuery/JavaScript code to continue to work.

    0 讨论(0)
  • 2021-01-13 08:23
    <script type="text/jscript">
    

    is probably not going to fire in Firefox: JScript is Internet Explorer's interpretation of JavaScript. Use

    <script type="text/javascript">
    

    Other than that, it looks like it should work fine (even though it would be really better and cleaner to have this stuff in the head part.)

    0 讨论(0)
  • 2021-01-13 08:27

    If one jQuery(document).ready block has an error inside it, later document.ready blocks do not get performed.

    For example, if one wordpress plugin does error out inside its own jQuery(document).ready, then all following jQuery blocks in other plugins may start failing.

    Firefox 18, Chrome 23, Opera 12 behaves this way. jQuery v1.7.2

    Recently it caused some trouble to me, and I can't imagine why I never had to deal with this before.

    Possibly it is a jQuery bug/unintended behaviour.

    0 讨论(0)
  • 2021-01-13 08:35

    I'm afraid I have no idea about how to fix the $(document).ready function, but this question has some possible solutions on how to work around it. Not sure if that's what you're looking for.

    0 讨论(0)
  • 2021-01-13 08:43

    Btw, you can write it even shorter:

    $(function() {
    
    0 讨论(0)
提交回复
热议问题