locked
SharePoint and JavaScript RRS feed

  • Question

  • Hello -

    I am new to SharePoint.  I have been assigned a project at work to code 3 content areas that are collapsible/expandable.  Two of the content areas are very simple but the third area is an expandable/collapsible table.  So, there is one JavaScript for the two simple areas and then a different JavaScript for the table.  Unfortunately, when I paste in the code for the table it completely whites/blanks out the screen.  Unfortunately, I do not have a lot of resources in-house to assist me so I am trying to find the answers on my own.

    From what I have read, scripts used in SharePoint should be in a separate file in a Document Library and then called to from the Editable Content Area.  I am wondering if this is indeed the issue with the white screen OR if it is simply a matter that the JavaScripts are not playing nicely together.  Although, they test fine on the same page when testing via Dreamweaver in various browsers.

    Any assistance or guidance is greatly appreciated!!


    • Edited by Mike Walsh FIN Wednesday, May 25, 2011 3:12 PM Ask one question per thread. "The other issue ..." removed
    Wednesday, May 25, 2011 2:55 PM

Answers

  • Hi,

    Yes that's right to integrate JavaScript with SharePoint you have to separately upload it in the doc lib and then you have to write code to call that scrip to perform the function.

     Take a look @ 

    http://social.technet.microsoft.com/Forums/en-US/onlineservicessharepoint/thread/dbad963b-fefe-4b59-9768-7898009cad80

    http://www.sharepointkings.com/2008/06/using-simple-javascript-in-sharepoint.html

    And on the page where you have to use the function through JavaScript , add content editor web part and add codes to call JavaScript from the doc lib.

    hth


    Warm Regards, Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com/
    • Marked as answer by Peng Lei Wednesday, June 1, 2011 3:06 AM
    Wednesday, May 25, 2011 3:18 PM
  • > Yes that's right to integrate JavaScript with SharePoint you have to separately upload it in the doc lib and then you have to write code to call that scrip to perform the function.

    It's not a requirement that JavaScript have to be uploaded into a document library. You can add a content editor web part on a page and then insert your javascript code using the "Source Editor" of that web part when it's in edit mode.

    If the same piece of code going to be used in multiple pages, then it makes sense to upload it as a separate file in a document library and then refer to it using a content editor web part. This allows easier maintenance.

     


    Pman
    http://www.pmansLab.com/
    • Marked as answer by Peng Lei Wednesday, June 1, 2011 3:07 AM
    Thursday, May 26, 2011 1:04 AM

All replies

  • Hi,

    Yes that's right to integrate JavaScript with SharePoint you have to separately upload it in the doc lib and then you have to write code to call that scrip to perform the function.

     Take a look @ 

    http://social.technet.microsoft.com/Forums/en-US/onlineservicessharepoint/thread/dbad963b-fefe-4b59-9768-7898009cad80

    http://www.sharepointkings.com/2008/06/using-simple-javascript-in-sharepoint.html

    And on the page where you have to use the function through JavaScript , add content editor web part and add codes to call JavaScript from the doc lib.

    hth


    Warm Regards, Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com/
    • Marked as answer by Peng Lei Wednesday, June 1, 2011 3:06 AM
    Wednesday, May 25, 2011 3:18 PM
  • Thanks so much for your help!
    Wednesday, May 25, 2011 3:35 PM
  • > Yes that's right to integrate JavaScript with SharePoint you have to separately upload it in the doc lib and then you have to write code to call that scrip to perform the function.

    It's not a requirement that JavaScript have to be uploaded into a document library. You can add a content editor web part on a page and then insert your javascript code using the "Source Editor" of that web part when it's in edit mode.

    If the same piece of code going to be used in multiple pages, then it makes sense to upload it as a separate file in a document library and then refer to it using a content editor web part. This allows easier maintenance.

     


    Pman
    http://www.pmansLab.com/
    • Marked as answer by Peng Lei Wednesday, June 1, 2011 3:07 AM
    Thursday, May 26, 2011 1:04 AM