Javascript
-
Upload
guto-xavier -
Category
Technology
-
view
1.645 -
download
0
Transcript of Javascript
![Page 1: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/1.jpg)
JAVASCRIPT
![Page 2: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/2.jpg)
Linguagem de Programação Case sensitive Linguagem server/client side Sintaxe similar á linguagem C Pode ser incorporado ao arquivo HTML ou
em um .js próprio Funções
JavaScript
![Page 3: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/3.jpg)
Incorporado ao HTML deve ser inserido entre as tag’s <script>:
<script type="text/javascript" language="javascript">document.getElementById('mensagem').innerHTML = 'Seja Bem Vindo';
</script>
JavaScript
![Page 4: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/4.jpg)
Conjunto de código que ao ser “chamado” executa alguma tarefa/operação.
Funções nativas Funções criadas pelo programador
Função
![Page 5: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/5.jpg)
Entrada de dados Saída de dados Estrutura de decisão Laços de repetição
JavaScript
![Page 6: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/6.jpg)
Eventos Prompts (Janela com campo de texto) Confirm Formulários
Entrada de Dados
![Page 7: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/7.jpg)
Qualquer acontecimento (click, carregar, passar o mouse, pressionar uma tecla) no navegador.
Quando ocorre um evento pode-se executar algum código javascript ou fazer a chamada para alguma função
Eventos
![Page 8: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/8.jpg)
onclick onload onblur onmousemove onselect onunload etc
Eventos
![Page 9: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/9.jpg)
<body onload="javascript:alert('Boa tarde!');">Minha página
</body>
Eventos
![Page 10: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/10.jpg)
var nome = prompt('informe seu nome','');
Prompt
![Page 11: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/11.jpg)
O valor do prompt deve ser armazenado em uma variável:
var nome = prompt('informe seu nome','');
Prompt
![Page 12: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/12.jpg)
var decisao = confirm('Continuar?');
Confirm
![Page 13: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/13.jpg)
O valor do confirm deve ser armazenado em uma variável:
var decisao = confirm('Continuar?');
Confirm
![Page 14: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/14.jpg)
Formulário
![Page 15: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/15.jpg)
Regatar valor de formulário: document.getElementById()
var nome = document.getElementById('campo_nome').value;
Formulário
![Page 16: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/16.jpg)
document.write alert Inserir valor em objetos HTML
Saída de Dados
![Page 17: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/17.jpg)
document.write(‘Boa Tarde’);
document.write
![Page 18: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/18.jpg)
alert('Boa Tarde');
alert
![Page 19: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/19.jpg)
InnerHTMLdocument.getElementById('mensagem').innerHTML = 'Seja
Bem Vindo';
Inserir valor em objetos HTML
![Page 20: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/20.jpg)
+ - / * =
Operadores
![Page 21: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/21.jpg)
== > < >= <= !=
Operadores
![Page 22: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/22.jpg)
if switch
Estrutura de decisão
![Page 23: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/23.jpg)
if (condição){
código se a condição verdadeira}else{
código se a condição falsa}
if
![Page 24: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/24.jpg)
if (15 == 50){ alert(“Resposta certa”);
}else{ alert(“Resposta errada”)
}
if
![Page 25: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/25.jpg)
For while do while
Laço de Repetição
![Page 26: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/26.jpg)
for (iniciação;condição;atualização){
comandos executados em cada interação}
for
![Page 27: Javascript](https://reader035.fdocumentos.tips/reader035/viewer/2022081508/5576244cd8b42a4e1c8b4ef6/html5/thumbnails/27.jpg)
for (numero=1; numero<=10; numero++){
alert (numero + " "); }
for