Question

I'm currently facing a strange problem with a javascript block and internet explorer 9. When I load the page the document ready function is not executed, actually it seems as no javascript at all is executed. When I reload the page a few times finally the script block is executed. I could not find any pattern when the script is executed.

<script type="text/javascript">
            $(document).ready(function() {
              console.log("ie test - start");
              $("#id_project").select2({ width: 'resolve' });
              $("#id_year").select2({ width: 'resolve' });
              $("#id_month").select2({ width: 'resolve' });
              $("#id_purchase_order_membership").select2({ width: 'resolve' });
              $("#id_action").select2({ width: 'resolve' });
              console.log("ie test - end");
            });

        $( document ).ajaxStop( function() {
              $("#id_project").select2({ width: 'resolve' });
              $("#id_year").select2({ width: 'resolve' });
              $("#id_month").select2({ width: 'resolve' });
              $("#id_purchase_order_membership").select2({ width: 'resolve' });
              $("#id_action").select2({ width: 'resolve' });
        });
    </script>

More strangely, when I start the developer tools of IE the script gets executed. It seems as I trigger something in IE with the start of the developer tools that lets IE remember that there is some js to be executed. Very strange. I will try to deploy an example script in the next days, as I understand that it will not be easy to help for such a strange problem. My test deployment is currently running in a login only site. Anyhow, maybe someone has faced the same issue..

Was it helpful?

Solution

As per my knowledge

 console.log();

is not working in IE. Remove these lines and try then

OTHER TIPS

It's a good practice to enclose your code in try-catch blocks. Javascript just crashes on error and terminates all scripts that come after that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top