Call Javascript Function on Postback

I ran into this problem when I had to call a javascript on page load after my server-side code threw an exception to the user.

If you want to call a javascript function on page postback, you'll need to add an EventListner to the current document.


<script language="JavaScript" type="text/javascript">

function doSomething(){.... }

if (window.addEventListener)
    window.addEventListener("load", doSomething, false);
else if (window.attachEvent)
    window.attachEvent("onload", doSomething);
else if (document.getElementById)
    window.onload= doSomething;



Comments have been disabled for this content.