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