JavaScript is used on a huge number of websites to add visual effects, validation, server interaction, and many more features. As JavaScript executes at the client side, it removes the latency involved with a round trip to the web server, resulting in more responsive applications and an improved user experience. JavaScript can also provide functionality that is not possible using HTML and server-side processing, for example, handling individual key clicks or mouse movements.
Visualforce has built-in capability to allow JavaScript interaction with the page controller. For example, the <apex:actionSupport />
component allows controller action methods to be called in response to JavaScript events, while the <apex:actionFunction />
component generates a JavaScript function that encapsulates a controller action method. Further, many components provide the on<event>
attributes, such as onclick
and onchange
, to allow custom JavaScript to be invoked in response to user...