I have a webpage that has some JavaScript in the <head> tag of the page. I need to dynamically add a JS Array on PageLoad into the <head> tag of the page. The code is adding the array into the <body> tag of the page, but the JS error and can not find array. Here is my VB code
The JS code works fine when the array is staticly added to the <head> tag. Does any know how to dynamically place JS code into the <head> tag of a page?
What doesn't kill you makes you stronger.
Code:
sScript.Append("<script language=javascript type=text/javascript>" & vbCrLf)
sScript.Append("var Pic=new Array();" & vbCrLf)
sScript.Append("Pic[0] = 'users/" & Img1 & "'" & vbCrLf)
sScript.Append("Pic[1] = 'users/" & Img2 & "'" & vbCrLf)
sScript.Append("</SCRIPT>" & vbCrLf)
Page.ClientScript.RegisterStartupScript(Me.GetType(), "ForceDefaultToScript", sScript.ToString)
The JS code works fine when the array is staticly added to the <head> tag. Does any know how to dynamically place JS code into the <head> tag of a page?
What doesn't kill you makes you stronger.