You need to sign in to do that
Don't have an account?
Hardik Chavda
How can I call javascript function when the apex page load ?
Hi,
I have to call javascript function at the time of page loading. Following is my code and explaination of what I want to achieve.
I have to call javascript function at the time of page loading. Following is my code and explaination of what I want to achieve.
<apex:page sidebar="false" controller="someController" > <script> function callThisFunctionAtThePageLoad(/*parameter will be passed from controller*/){ //alert('show this alert'); } </script> </apex:page>So here, I want to pass one parameter in function for condition checking, which will come from the controller.
All Answers
As Javascript is excuted as it order on Page i.e If you put you javascript code at end of all your code it will automatically get call after page Load.
If you are using Jquery try:
------------------------------------------------------------
$( document ).ready(function() {
console.log( "ready!" );
});
--------------------------------------------------------------------------
Please refer following doc for Jquery:
https://learn.jquery.com/using-jquery-core/document-ready/
If its helps, please mark as best answer so it will help to other who will serve same problem.
Thanks!
Thanks for the quick reply but I don't get you when you said that I have to put javascript at the end of the page. And I only want to use javasript so If you could give me a code example then it would be great.
Suppose you want to access one of Input on Page load then you have to place you javascript after that input to access it into your javascript.
As in above code you are calling "callThisFunctionAtThePageLoad" function after the <input> tag so you can access it in your javascript.
if you are trying to access it before the <input> tag you will get an error.
If its helps, please mark as best answer so it will help to other who will serve same problem.
Thanks!
Please mark as best answer so it will help to other who will serve same problem.
Thanks!