OnLoad function in visualforce

Method 1:

<script type = "text/javascript">
    window.onload=function()      
    {        
        alert("Hi");
    };
</script>

Method 2:

Visuaforce page:

<apex:page action="{!onLoad}">

</apex:page>


Controller:

public class sample {
        public sample(){
        }

        public void onLoad(){

            ..................
            ..................
        }
}


Cheers!!!

4 comments: