Javascript no intrusivo

Forma de usar Javascript fuera del flujo HTML:

1
2
3
4
5
6
7
8
9
10
11
12
<head>
  <script type="text/javascript">
    window.onload = function() {
      var reloj = document.getElementById("reloj");
      var fecha = (new Date()).toLocaleString();
      reloj.innerHTML = fecha;
    }
  </script>
</head>
<body>
  <div id="reloj">No te puedo mostrar la hora</div>
</body>

Tags: , ,

Comments are closed.