we have a Javascript sheet saved as a static resource and one of our developers is attempting to invoke a function from it in our visualforce page.

In our visualforce page, we are using:

<apex:includeScript value="{!$Resource.QA_Javascript}"/>

And we are trying to call a function for an onlabelclick on a pageBlockSection Item.

When we put the function in the top of the page within <script> tags it works fine, but we are trying to avoid that to keep the page cleaner. Any help is appreciated.

  • 1
    QA_Jacascript is a single JS file or a JS file inside of a zip?
    – greenstork
    Commented Oct 8, 2014 at 17:51
  • At this point a single file, thats why we didn't use the URLFOR
    – GeorgeA
    Commented Oct 8, 2014 at 17:55
  • 1
    have you tried to invoke the function by using onclick="QA_Javascript.function();" ( assuming the filename that is sitting in the static resource is QA_Javascript.) reference : stackoverflow.com/questions/6806246/…
    – Rao
    Commented Oct 8, 2014 at 18:15
  • @rao I tried that as well...no success. Below is my code, is my include script misplaced or anything? <apex:page standardController="QA__c"> <apex:includeScript value="{!$Resource.QA_Javascript}"/> <apex:form > <apex:pageMessages /> <apex:pageBlock title="QA Scoring Form">
    – GeorgeA
    Commented Oct 8, 2014 at 18:57
  • 1
    @GeorgeAlbrechtwhere are you calling the method in your static resource? Are you seeing any errors in the javascript console of the browser?
    – Phil B
    Commented Oct 8, 2014 at 19:25

2 Answers 2



<apex:includeScript value="{!$Resource.QA_Javascript}"/>

should work fine. Make sure that you have put the correct name though. In this case, QA_Javascript needs to be the name of the Static Resource not the name of the file itself.

Then, to reference a named function from your javascript in the onlabelclick call on a pageBlockSectionItem simply write:

<apex:pageBlockSectionItem onLabelClick="YourFunctionName()">

No need to write the file name before your function call.

  • Thanks @Kyle this is exactly how I have it set up currently.
    – GeorgeA
    Commented Oct 8, 2014 at 19:51

Found the answer, in QA_Javascript Static resource, I saved the file as a .js, but still included tags. Since removed and fixed, thanks for all of the help everyone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .