This is my code, and always returns Null in the "if" sentence. The id exists. When I try to do document.getElementById
in the console, it runs properly.
<apex:component>
<script type="text/javascript">
function refresh() {
var run = document.getElementById('db_ref_btn');
if (run == null) {
alert('Por favor, añade un Informe a la página de Inicio.');
} else {
document.getElementById('db_ref_btn').click();
}
}
window.onload = setInterval(refresh);
</script>
</apex:component>