Yashwant Kumar Sahu Yashwant Kumar Sahu - 1 year ago 77
Javascript Question

How to run java script code before page load?

I have working in asp.net web application. Here I need to run javascript before page load.

I have gone through

<body oninit="funinit();" onprerender="funRender();" onload="funload();">


<script type="text/javascript" language="javascript">
function funinit() {
function funload() {
function funRender() {


here only funload() is working.
plz give me any solution to run script before page load.

Answer Source

You can use window.onpaint for such purpose like :

<script type="text/javascript">
    function preloadFunc()
    window.onpaint = preloadFunc();

I hope it helps you....