<head> <script> onload=function(){ if(!document.getElementById('pepe')){ alert('no existe el id pepe'); }else{ alert('sí, existe el id pepe'); } } </script> </head>