Consider the following:
<head>
<script src="somejsfile.js"></script>
<script>
var firstScript = document.getElementsByTagName("script")[0];
firstScript.innerScript = firstScript.innerScript.replace("foo","test");
</script>
</head>
somejsfile.js:
console.log("foo");
Now, this (pseudo)code is for illustration only; it does not work, because there is no innerScript
element. So, is there a way to get/manipulate console.log("foo");
using JavaScript DOM manipulation, in a similar way to iframe.innerDocument
?
(EDIT: If you would like to know what I need it for:
I am trying to debug whether the script file is loaded or a 404 is occurring. My script contains console.log in the first line, and that line is not executed inside my WP8 xap cordova application.)