Connecting Tech Pros Worldwide Forums | Help | Site Map

how to ouput script tags on html page

Newbie
 
Join Date: Nov 2008
Posts: 29
#1: Nov 18 '08
hello

i have no problem with this code:
Expand|Select|Wrap|Line Numbers
  1. var z=new Array()
  2. z[0]="<span style ='color:red;'>yeah</span>"
  3. document.getElementById("aa").innerHTML = z[0];
it ouputs everything and also with the style.

but if i do:
Expand|Select|Wrap|Line Numbers
  1. var z=new Array()
  2. z[0]="<script src='http:\/\/feed2js.org\/\/feed2js.php?src=http%3A%2F%2Fwww.lemonde.fr%2Frss%2Fune.xml&amp;num=2&amp;desc=100&gt;1&amp;date=y'><\/script>"
  3. document.getElementById("aa").innerHTML = z[0]
it wont ouput the script source wich is a rss feed source, how can i append to the html body the script tag?

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,662
#2: Nov 18 '08

re: how to ouput script tags on html page


not at all, because script references belong in the document head. and you're missing the type attribute.

regards
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#3: Nov 19 '08

re: how to ouput script tags on html page


Yes, create a script element using document.createElement, set its properties and then append to the head: document.getElementsByTagName("head")[0].
Reply


Similar JavaScript / Ajax / DHTML bytes