I have a function in JS to preview images in filupload control:
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
var uplImg = document.getElementById('preImg');
uplImg.setAttribute('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
var fu = document.getElementById("fuImagenCliente");
fu.onchange(function() {
readURL(this);
})
</script>
Chrome and Firefox don´t catch the error and "works fine" but in javascript console I see error:
Cannot read property 'onchange' of null (Chrome)
Uncaught TypeError: Cannot read property 'onchange' of null (Firefox)
However IE 11 yes he does:
Error IE11
The function that is executed in the event onchange
expect a parameter but I do not know what parameter to pass to this, just need this parameter.
Information
When I debug, I see that the ClientClient control is not loaded, I am working in ASP.Net and surely the function is trying to find a control which has not yet been loaded.