I have a html
file and has a div
containing a image src
<div id="imageoutput"><img id="imgoutput" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA"></div>
I ignored some of the Base64 data here because it is too long, just for your convenience to read the code.
So I have a javascript
file included in the HTML
.
document.onload = function () {
var existingData = document.getElementById('imgoutput').src;
}
I wanna get the src
for this image when the page is loaded, but seems like when I
console.log(existingData)
it will give me this error all the time
Uncaught ReferenceError: existingData is not defined
but if I do
console.log(document.getElementById('imgoutput').src)
It will give me the image src
EDIT
If I did this all wrong, what is the possible way to get the image src out and store it in a variable?