Search code examples
javascriptsharepointsharepoint-2010web-parts

Content editor webpart script does not run in IE 11 (runs if developer tools are open)


<script type = "text/javascript" src = "/SiteAssets/jquery-2.2.2.min.js">  </script>
 <script type = "text/javascript" >

$(function () {
    console.log('ready');
    MyFunction();
});

I am trying to run a simple script in a content editor webpart (SharePoint Server 2010) on a site page in a team site.

The script runs successfully (above) if the developer tools window is open in IE11. If the developer tools are not open the script does not even run. I have tried using alert too instead of console.log but there is no output if developer tools is closed.

Site was added to the compatible view sites before and i tried removing the site and still similar behaviour. I tested the same script in my dev server and the production server with similar output.

Is there a known issue with content editor webpart and IE11 as my googling effort was not able to find.

Any help is appreciated.

Thanks
Rahul


Solution

  • The problem is console.log('ready'). This statement throws an error in Internet Explorer if there is no console to write to.

    The console is only available when the developer tools are open.