Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert JS into Page Head

Status
Not open for further replies.

EZEason

Programmer
Dec 11, 2000
213
US
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

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.
 
Can you provide an example, I'm not sure I follow.

What doesn't kill you makes you stronger.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top