INVESTIGACION de JAVA SCRIPT:
Javascript es diferente a
java tienen semánticas y propósitos diferentes tiene sintaxis parecida
al C. La utilización este mejora la interfaz con el usuario y paginas web dinámicas.
Surge para extender las capacidades del html. Sus comandos los analiza el HTML
cuando deben ser ejecutados los comandos por eso es un lenguaje embebe.
Ejemplo:
<html>
<head>
</head>
<body>
<script language="javascript">
document.write('Hola Mundo');
</script>
</body>
</html>
Este código es el que inicializa el javascript:
<script
language="javascript">
</script>
Para imprimir datos es el comando write
document.write('Hola Mundo'); son olvidar que la información
debe ir entre comillas simples
EL JAVASCRIPT es sensible a MAYUSCULAS y minúsculas.
OTROS EJEMPLOS:
Acceder al elemento HTML con el id especificado y cambiar su
contenido:
<html>
<html>
<body>
<h1>My First Web Page</h1>
<p id="demo">My First Paragraph</p>
<script>
document.getElementById("demo").innerHTML="My First JavaScript";
</script>
</body>
</html>
<html>
<body>
<h1>My First Web Page</h1>
<p id="demo">My First Paragraph</p>
<script>
document.getElementById("demo").innerHTML="My First JavaScript";
</script>
</body>
</html>
2.- El siguiente ejemplo escribe un
elemento <p> directamente en la salida de documentos HTML:
<html>
<html>
<body>
<h1>My First Web Page</h1>
<script>
document.write("<p>My First JavaScript</p>");
</script>
</body>
</html>
<html>
<body>
<h1>My First Web Page</h1>
<script>
document.write("<p>My First JavaScript</p>");
</script>
</body>
</html>
3.- MOSTRAR ADVERTENCIA
<html>
<body>
<h1>My First Web Page</h1>
<p>My First Paragraph.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
document.write("Oops! The document disappeared!");
}
</script>
</body>
</html>
No hay comentarios:
Publicar un comentario