Adding Javascript to the BODY tag in DNN
When working with .ascx skin files, you will sometimes need to add some Javascript to the BODY tag, such as something that runs when the OnLoad event triggers.
Well, you can always add a BODY tag inside your .ascx file along with the Javascript you like and hope that the browser will understand that. Essentially, you'll end up having two BODY tags in your source code-one that is generated by DNN and one that is typed by you. Some browsers (like Chrome) understand what's happening and try to transfer the Javascript to the actual BODY tag when rendering the page, but others don't.
What you can do, though, is create a Page_Init event handler inside your .ascx file and put this code there:
body.Attributes("onload") = "blablablaJavascript"
Where blablablaJavascript is your Javascript. Of course, you can do that for other events (even for other tags) as well.
If you're using a single .ascx file with no code-behind (like most do), you'll want to define a Page_Init event there. You can do that like this:
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'Add your code here
End Sub
</script>