Hi,
How to execute a javascript function when the asp.net webpage is first loaded? or refreshed?
Currently, I put the javascript function in the Page_Load Method. Visual Studio 2005 is used. The asp.net language is in vb.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Page.RegisterStartupScript("MyScript", _
"<script language = javascript>" & _
"function showIFrame(){" & _
"var iframe = document.createElement(iframe);" & _
"iframe.ID = testiframe;" & _
"iframe.name = testiframe;" & _
"iframe.frameborder = 1;" & _
"iframe.style.top = 200;" & _
"iframe.width = 175;" & _
"iframe.scrolling = auto;" & _
"iframe.src = C:\Test.html;" & _
"window.document.body.appendChild(iframe);" & _
"return false;" & _
"}" & _
"</script>")
Button1.Attributes("onClick") = "return showIFrame()"
End Sub
The jscript above can correctly display an IFrame when the button is clicked. But how to make the javascript execute by itself when the webpage loads?

How to execute a javascript function when the asp.net webpage is first loaded? or refreshed?
Currently, I put the javascript function in the Page_Load Method. Visual Studio 2005 is used. The asp.net language is in vb.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Page.RegisterStartupScript("MyScript", _
"<script language = javascript>" & _
"function showIFrame(){" & _
"var iframe = document.createElement(iframe);" & _
"iframe.ID = testiframe;" & _
"iframe.name = testiframe;" & _
"iframe.frameborder = 1;" & _
"iframe.style.top = 200;" & _
"iframe.width = 175;" & _
"iframe.scrolling = auto;" & _
"iframe.src = C:\Test.html;" & _
"window.document.body.appendChild(iframe);" & _
"return false;" & _
"}" & _
"</script>")
Button1.Attributes("onClick") = "return showIFrame()"
End Sub
The jscript above can correctly display an IFrame when the button is clicked. But how to make the javascript execute by itself when the webpage loads?