how to ouput script tags on html page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arty
    New Member
    • Nov 2008
    • 35

    how to ouput script tags on html page

    hello

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

    but if i do:
    Code:
    var z=new Array()
    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>"
    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
    Recognized Expert Expert
    • Aug 2008
    • 8694

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

    regards

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Yes, create a script element using document.create Element, set its properties and then append to the head: document.getEle mentsByTagName( "head")[0].

      Comment

      Working...