Dynamically switch Javascript

Giganews Newsgroups
Subject: Dynamically switch Javascript
Posted by:  William Pierce (evalsin…@hotmail.com)
Date: Mon, 25 Sep 2006


I have an interesting problem that I am stuck on and was wondering if there
might be others who can shed some light....

Basically,  within an HTML page,  I have a tag that looks as follows:
        <div id="xxx">


A call gets made to a server,  and it returns a string.  The string will be
well-formed HTML.  In most cases,  all I do is

document.getElementById("xxx").innerHTML = <string>

However,  sometimes,  the string that may be returned by the server may be a
string that looks as follows:
        <script language="JavaScript" src="path/to/js"></script>

In this case,  I need to be able to execute this Javascript and place its
contents inside the "div" tag.

I have tried using "eval()" and also constructing a script node dynamically
and both have not worked for me.

Thanks in advance for your help!

-- wp