+ Start a Discussion
Ashok S 7Ashok S 7 

how can use static resource in visualforce page

Hai,
I am using static resource in my visual force page. But in that visual force i used alert message and toggle function. but it is not working properly.I tried but it is not comming.
Vf page
--------------------------
<apex:page >
  <apex:includeScript value="{!URLFOR($Resource.jqueryui,'/Naveen/jquery/jquery.js')}"/>
  <apex:includeScript value="{!URLFOR($Resource.jqueryui,'/Naveen/jquery/jquery-ui.js')}"/>
  <script>
  j$=jQuery.noConflict();
  if(j$){
            alert('Success');
  }
  else
  {
            alert('Failure');
  }
  function show()
  {
      j$('[id$=one]').toggle()
  }
  </script>
  <apex:pageBlock id="pb" title="FirstBlock" onmouseover="show()">
  This is Block one
  </apex:pageBlock>
  
  <apex:pageBlock id="one" title="FirstBlock">
  This is Block one
  </apex:pageBlock>
</apex:page>

Any one help me to slove this.Please.
Tintu_BabuTintu_Babu
Hi,

Can you check the path of resource file. make sure it is loading correctly using inspect element sources.
PawanKumarPawanKumar
Hi Ashok,
I am assuming you have uploaded zip file as static resource and the zip folder name is 'Naveen'. So you try the below line.

<apex:includeScript value="{!URLFOR($Resource.Naveen,'Naveen/jquery/jquery.js')}"/>

Regards,
Pawan Kumar

PS: Please let me know if it helps you. 
Ajay K DubediAjay K Dubedi
Hi,
Try the below code it works fine with your requirement.
<apex:page >
    <apex:includeScript value="{!URLFOR($Resource.JQueryMinJs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.JQueryDataTable)}"/>
    <script>
    j$=jQuery.noConflict();
    if(j$){
        alert('Success');
    }
    else
    {
        alert('Failure');
    }
    function show()
    {
        j$('[id$=one]').toggle()
    }
    </script>
    
    <apex:pageBlock id="pb" title="FirstBlock" onmouseover="show()">
        This is Block one
    </apex:pageBlock>
    
    <apex:pageBlock id="one" title="FirstBlock">
        This is Block one
    </apex:pageBlock>
</apex:page>
You should check your static resource files.

I hope you find the solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi