By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,521 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,521 IT Pros & Developers. It's quick & easy.

how to ouput script tags on html page

P: 35
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?
Nov 18 '08 #1
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
not at all, because script references belong in the document head. and you're missing the type attribute.

regards
Nov 18 '08 #2

acoder
Expert Mod 15k+
P: 16,027
Yes, create a script element using document.createElement, set its properties and then append to the head: document.getElementsByTagName("head")[0].
Nov 19 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.