You need to sign in to do that
Don't have an account?

using JS from static resource from onclick javascript on custom button
I want to access some JS function defined in static resource java file from Javascript on custom button.
anybody knows how to do this?
1. Upload you JS file(Ex:- myScript.js) in to StaticResources.
2. Give it a name(Ex:- mySample).
3. If your JS file has a function named as "myFunction()" you can access that method in VF page as below.
<apex:page>
<apex:includeScript value="{!$Resource.mySample}"/>
<apex:form>
<apex:commandButton value="Click Me" onclick="myFunction();"/>
</apex:form>
</apex:page>
sorry for bad english used in previous query..
Actual scenario is like this..
I am creating custom button using custom buttons&links. It gives me options do link it to VF page
or S-control or Javascript which I can write on same page.
In that javascript, I want to write some JS code which will be used in more than one custom buttons.
so I wanted to refactor it. which is why I want to move this code into Static resource file. and call that
js function from every custom button javascript code..
Setup->Customize->Contact->buttons & links , in this click on New under custom buttons and Links
I hope I am described problem clearly now.
I actually have the same question and was wondering if you have found a solution? Thanks!
JoAnn
Any ideas on how to do it ?
We ended up re-writing the javascript and setting the link to be a custom link that called an onClick javascript and passed a field value to it. It seems to be working pretty well. It's much easier to do it in VisualForce though using prageeth's example above. If I had had the option of going with a VF page I would have done it that way.
JoAnn