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

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.php?;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

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

Nov 18 '08 #2

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.