You need to sign in to do that
Don't have an account?
Tristan
Using JavaScript in a Static Resource from an OnClick Custom Link
I'm looking to replace a custom link that pops up an SControl with a new one of the "OnClick JavaScript" variety. I've put the bulk of the code into functions in a JavaScript Static Resource file, and was hoping to reference that from the OnClick link with a {!REQUIRESCRIPT("{!URLFOR($Resource.MyJSLib)}")} or similar, but I can't get that to work.
{!REQUIRESCRIPT("/resource/magic-id/MyJSLib")} does work, but is obviously not really production quality or packagable.
Anybody have ideas how this should be done?
URLFOR returns a relative URL for a static resource archive in a Visualforce page. You could have your custom link reference a Visualforce page that calls your static resource.
Hope that helps,
Sati
I have indeed turned JavaScript code into a Apex custom controller behind a Visualforce page in my managed package (thanks!), but not quite as SF intended.
I'm still using On Click Javascript still to call window.open("\apex\MyNamespace__MyApexPage?opt1=stuff&opt2=otherstuff", ...). This is because I need to pass in arguments whereas the custom-link option for directly using Visualforce pages does not allow this, plus only having a single page rather than having one per SObject is nice.
So far it works, hopefully that will continue!