Activity Forums Salesforce® Discussions How can we call the javascript function from the Salesforce Apex class?

  • Tanu

    Member
    September 20, 2016 at 6:37 am

    Hello Mohit,

    Try this,

    <apex:page controller="calljavascript_cls" >

    <script>

    function func()

    {

    alert('function calling');

    }

    </script>

    <apex:outputText value="{!callfunc}" escape="false"></apex:outputText>
    <apex:outputText value="{JavaScript}" ></apex:outputText>
    </apex:page>

    -------------------------------

    apex controller

    public class calljavascript_cls

    {

    public string callfunc{get;set;}

    public calljavascript_cls()

    {

    callfunc='<script> func(); </script>';

    }

    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Pros & Cons of Lightning Component vs. 3rd party frameworks in Salesforce UI development

Video in

Nikita drops by to share his invaluable experience of using popular 3rd party frameworks in Salesforce. http://media.blubrry.com/salesforceway/audio.xmcdn.com/group42/M05/25/57/wKgJ81rXk6XjaZIAAU_I_KtprFM998.m4a