call javascript function on content page body load


Today i faced one problem in content page. I would like to share it with you.

Today I have derived content page from master page and I want to call one javascript function on body onload event. You know that, There is no body tag in content page.

I have used below different ways to call it.
1. I have used window.onload event like
window.onload = fnName();
Generally this is working in simple html and javascript page but this doesn’t work for me

2. I have used javascript pageload function but it doesn’t work for me

3. I have make master page body tag to runat as server and created one property for accessing it.
After that I have accessed it from content page but it doesn’t give me solution for my problem

4. Lastly I have used javascript addEventListener event for registering a load event like
window.addEventListener(‘load’, function () { fnName() }); and I got the solution.

Hope this will help you.