I'm trying to output a <script>
element in an innerHTML:
<script type="text/javascript">
function fileManager()
{
data = document.getElementById("FM");
data.innerHTML = "<script type='text/javascript' src='functions.js'></script>";
}
</script>
<div id="FM"></div>
<ul id="show-menu">
<li onClick="fileManager()">File Manager
</ul>
The innerHTML bit of the script works perfectly, it's just that there's a problem with escaping characters inside the double quotes ("). The whole <script type='text/javascript' src='functions.js'></script>
seems to be broken/written incorrectly and I can't seem to figure out what's wrong with it.
In case you're wondering, the functions.js file contains only document.write("test");
for testing purposes.
For some unknown reason this does not work. The result is a broken page, I see bits of other functions in the script and it doesn't make sense. How do I escape it correctly?