Content Editor Web Part Site Relative JavaScript

Issue I need to insert a custom Javascript file into my page.

Resolution Adding a CEWP to the site and editing the HTML.

<script type="text/javascript">
document.write('<script',
' src="' + L_Menu_BaseUrl +'/ScriptLibrary/MyAwesomeJavascript.js"',
' type="text/javascript"><\/script>');
</script>

One thing to keep in mind is that you want the script to be site relative and that means it must run across your farm, not just a server I found a post that pointed this out and adjusted my code to include the L_Menu_BaseUrl variable.Thank you Kjell-Sverre

Adrian

0 views0 comments