I have this code from an example which outputs to console.log:
<script>
function readDataUrl(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
console.log("Read as data URL");
console.log(evt.target.result);
};
reader.readAsDataURL(file);
}
</script>
However, I want to output it to innerHTML, but it doesn’t work. Why not? Is the syntax wrong?
<p style="text-style:italic">Read As DataURL:</p>
<p id="dataUrl"></p>
<script>
function readDataUrl(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
var element = document.getElementById('dataUrl');
element.innerHTML = evt.target.result;
};
reader.readAsDataURL(file);
}
</script>
I tried downloading cordova.js from its GitHub repo, but I got the error
Uncaught ReferenceError: require is not defined
What I had intended (and I’m sorry if I miscomunicated this) was that you post enough code or make a JS fiddle that I can run and see the appropriate output in the the console (without me having to hunt around the internet for libraries).
I can then hopefully tell you the best way to achieve your aim and inject the output into the DOM as opposed to log it to the console.
I would like to see an example of your script working.
That is to say a link I can visit, a JSFiddle, or enough code that I can copy and paste to run this locally.
As it is, I’ve not much idea what this script should do, how to run it, or what dependencies it has