function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
devNut!devNut! 

Hooking into "onLoad" event in Visualforce page

Hi,
Is it possible to define some javascript that runs when a visualforce page loads (not necessarily for the first time)?


Thanks!
JimRaeJimRae
The using Browser Technologies series has a reference to how to add a javascript onload function.
 
Here is a code snippet from that series:
 
Code:
<script>
      window.onload = new function() { submitForm(); };
      function submitForm() {
        textFld.value = "Set from onLoad event";
        btnCopy.click();
      }
      function changeValue() {
        otherName.value = "NO MORE LOREM IPSUM";
        return true;
      }
    </script>

 
devNut!devNut!
Thanks for the reply!

Another way i found is to just put a script section containing js code at the bottom of the page before the </form> tag.  This code will run when the page loads.


sfd007sfd007

Thanks for the other way!

nagalakshminagalakshmi

Hi jimrae,

 

I am displaying my visual force page as pdf. I want to display the alert box when i execute that page. Please help me how to solve this. i tried a lot but not getting. Please help me.

 

 

Thanks,

Lakshmi.