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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

createElement('SCRIPT')

Status
Not open for further replies.

pcawdron

Programmer
Jun 14, 2000
109
AU
Has anyone ever tried this???

Look at this example, the first one works, the second doesn't

var DAx=document.createElement('FONT')
var DAtxt=document.createTextNode('Hello')
DAx.setAttribute("color","Red")
DAx.setAttribute("ID","NewFont")

DAx.appendChild(DAtxt);
PreviewPane.appendChild(DAx);

alert(DAx.innerHTML)


Works fine, but change it to...

var DAx=document.createElement('SCRIPT')
var DAtxt=document.createTextNode("alert('Hi')")
DAx.setAttribute("language","javascript")
DAx.setAttribute("ID","NewScript")

DAx.appendChild(DAtxt);
PreviewPane.appendChild(DAx);

alert(DAx.innerHTML)


PreviewPane is a DIV element I'm using for testing. The first script places a nice red hello in the DIV, followed by an alert box, the second does NOTHING....

Any ideas or suggestions are certainly welcome.

Thanks,
Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top