You need to sign in to do that
Don't have an account?
sreeja
Adding Javascript in salesforce
Hi , i had added the alert.js file in saticresource as alert.
alert.js:-
and in the Visualforce page :
functionality is not getting work .. thanks
alert.js:-
<script> function myFunction() { alert("I am an alert box!"); } </script>
and in the Visualforce page :
<apex:page > <apex:includeScript value="{!$Resource.alert}"/> <apex:includeScript value="{!URLFOR($Resource.alert, 'alert')}"/> <apex:stylesheet value="{!URLFOR($Resource.alert, 'alert')}"/> <button onclick="myFunction()">Try it</button> </apex:page>
functionality is not getting work .. thanks
Remove <apex:includeScript value="{!URLFOR($Resource.alert, 'alert')}"/> and <apex:stylesheet value="{!URLFOR($Resource.alert, 'alert')}"/> .
Please refer to these links it may be helpful to you:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_includeScript.htm
https://developer.salesforce.com/forums/?id=906F0000000BXFQIA4
https://salesforce.stackexchange.com/questions/132042/display-an-alert-on-the-visualforce-page-from-controller
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
i have an alert.js file , i had added it to static resource and saved as alert. i need to call the staticresource in visualforce page, for acheiveing the button onclick functionality .
thanks..
You can call your static resource as follows:
<apex:includeScript value="{!$Resource.MyJavascriptFile}"/>
Please refer to the following link as they may be helpful:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources_reference.htm
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources_iframe.htm
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha