Execute Custom JavaScript code in SharePoint Content Editor webpart
When we try to execute a custom java script code in SharePoint content editor web part, it may not work. The reason behind is that, there might be a conflict occurring during load.
Microsoft provides ways to launch your function after full page load and following is one of the method.
<script type="text/javascript"> _spBodyOnLoadFunctionNames.push("LaunchCustomCode"); LaunchCustomCode = function() { ExecuteOrDelayUntilScriptLoaded(MyCode, "sp.js"); } MyCode = function() { console.log('My Code Start'); alert('MyCode Called'); console.log('My Code Finish'); } </script>