function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rakesh Kumar 25Rakesh Kumar 25 

Executing Javascript from Custom Link

I have a piece of Javascript code running fine on a Visualforce Page.The code is referring to a Static resource and it is also working fine.
I need to execute the same JS through custom link ,so that it can be added as a sidebar component on standard pages.
Can someone please suggest what modifications need to be done to the JS so that it can work from Custom Link.

Thanks,
Rakesh 
Pankaj_GanwaniPankaj_Ganwani
Hi,

Can you please share your code your here if possible?
Rakesh Kumar 25Rakesh Kumar 25
Below is the code working fine in VFP.

<script language="JavaScript" type="text/javascript" src="https://cs21.salesforce.com/resource/1426565202000/code_new"></script>
<script language="JavaScript" type="text/javascript">
s.prop1="VAR1" ;
s.prop2="VAR2" ;
s.prop3="" ;
s.prop4="1111111111111" ;
s.prop5="VAR5" ;
var s_code=s.t();if(s_code)document.write(s_code)</script>
<script language="JavaScript" type="text/javascript">
if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
</script> 
Pankaj_GanwaniPankaj_Ganwani
Hi,

Please remove the script tags from the code to refer the static resources and use{!URLFOR} or {!REQUIRESCRIPT} instead.
Please go through this post:
http://www.interactiveties.com/b_execute_javascript_button.php#.VTqASOH7zKg
Rakesh Kumar 25Rakesh Kumar 25
Hi,

Thanks for the suggestion.
I tried the approach as suggested.
It is giving the below error :
"Object does not support property or method 't' ".
This method is availabe in the static resource.

Thanks,
Rakesh