Oscar said:
I´m trying to make an application with if ...something
else if ... something else to dinamically change a src script,
can't this be done ? and if so why not ?
JavaScript defined in a script block is executed as and when the HTML
page is initially interpreted. This includes reading in any functions
defined in the script block. If you try programmatically changing the
content of a script block, I don't think the behaviour is defined.
However, a possibility is to do something like
<script type="text/javascript"><!--
document.write('<script type="text/javascript" src="a.js"><\/script>');
// --></script>
Note the backslash, which makes extra sure that the closing script tag
that you write out isn't interpreted as the end of this code.
The exact time at which the included script is processed in relation to
the script that includes it isn't well defined. You'll need to end this
script block and start another before you can use functions defined in
the .js file.
<span id="script">
<script type="text/javascript" >
script.innerHTML="script src='a.js' ";
</script>
If this worked, you would end up with
<span id="script">script src='a.js' </span>
which obviously isn't what you intended. Before you count the fact that
you have nothing with a _name_ (as opposed to id) of script.
Stewart.