Monday, May 20, 2024
39
rated 0 times [  40] [ 1]  / answers: 1 / hits: 69557  / 15 Years ago, wed, june 3, 2009, 12:00:00

I have an aspx that has the following javascript function being ran during the onload event of the body.



<body onload=startClock();>


However, I'm setting the aspx up to use a master page, so the body tag doesn't exist in the aspx anymore. How do I go about registering the startClock function to run when the page is hit and still have it use a masterpage?


More From » master-pages

 Answers
207

If you don't want to explicitly assign window.onload or use a framework, consider:



<script type=text/javascript>
function startClock(){
//do onload work
}
if(window.addEventListener) {
window.addEventListener('load',startClock,false); //W3C
} else {
window.attachEvent('onload',startClock); //IE
}
</script>


http://www.quirksmode.org/js/events_advanced.html


[#99394] Saturday, May 30, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
billie

Total Points: 101
Total Questions: 114
Total Answers: 98

Location: Burundi
Member since Wed, Nov 25, 2020
4 Years ago
;