Monday, December 19, 2011

How to troubleshoot when the Java scripts does not work in Sharepoint

In most cases where users have trouble getting my solutions to work, the problem is the script references. I will give a few examples here on how to troubleshoot these cases.

To copy the script from sourcecode provided in the article, hover over the script and click “view source”. Highlight, copy and paste in notepad. Save with the correct file extension like this:

1)Select “Save as” from the file menu and be sure to use the “.js” extention in the file name. Below the file name, you find a drop down where you can set the file type.

2)Select “All files”. If you don not do this the file will be saved as “fielname.js.txt”.

To check that the scripts are referred correctly, insert an alert in the CEWP like this:

<script type="text/javascript" src="/MyFolder/Test/Javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
  // Check that jQuery is loaded:

  // Check that a specific function is loaded:

Both these alerts should give a dialog box with the text “function”. If you get “undefined”, the script reference are wrong.

Another thing:
In most cases the CEWP must be placed below the list for or list view for the code to work.

No comments:

Post a Comment