Activity Forums Salesforce® Discussions Is it possible to call javascript function in an apex controller? Reply To: Is it possible to call javascript function in an apex controller?

  • Parul

    Member
    September 19, 2018 at 9:08 pm

    Hi,

    Try it

    <apex:page controller="calljavascript_cls" >

    <script>

    function func()

    {

    alert('function calling');

    }

    </script>

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

     

    </apex:page>

    -------- apex class --------------

    public class calljavascript_cls

    {

    public string callfunc{get;set;}

    public calljavascript_cls()

    {

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

    }

    }

    Hope this helps.

    Thanks.