Developers who are experienced in traditional web applications in Lotus Notes it becomes a nightmare when they start to work with XPages.
One of the initial issues that I faced is - the struggle to gain control of the onload event in the XPages as the available events in the XPages like the afterPageLoad etc... only allows Serverside script and it becomes expensive to hit the server every time in terms of application's performance.
The following code fragment shall help people who face this issue, and will help them gain access to the XPage's onload event.
XSP.addOnLoad(alert('I am in XPage onload'));
Add this snippet of code in the Source panel and ensure that it is not nested inside any other existing tags.An ideal place would beneath the lines which say (sort of),
<?xml version="1.0" encoding="UTF-8"?>
Now after performing the above step, preview your XPage and voila, you will get the alert saying "I am in XPage onload"