Vous êtes sur la page 1sur 2

Exemplos Programao Client Side - Javascript

CURSO: Tcnico/a de Informtica - Instalao e Gesto de Redes Ano Lectivo: 2010 / 2011 Disciplina: Servidores WEB Nome do Formador: Lus Alves Plo: Castelo Branco

1. Chamar funo Javascript a partir de um link:


<html> <body> <a href="javascript:alert(Executar uma funo um link')">clique aqui para executar</a> </body> </html>

a partir de

2. Informaes do browser
<html> <head> <title></title> </head> <body> <script type="text/javascript"> <!-document.write("O seu web browser o: "+ navigator.appName) // --> </script> </body> </html>

3. Informaes da resoluo
<html> <head> <title></title> </head> <body> <script type="text/javascript"> <!-document.write("SCREEN RESOLUTION: ") document.write(screen.width + "*") document.write(screen.height + "<br>") document.write("AVAILABLE VIEW AREA: ") document.write(window.screen.availWidth + "*") document.write(window.screen.availHeight + "<br>") document.write("COLOR DEPTH: ") document.write(window.screen.colorDepth + "<br>") // --> </script> </body> </html>

4. Tremer o browser
<html> <head> <title>Untitled</title> <script> function tremer(n) { if (self.moveBy) { for (i = 10; i > 0; i--) { for (j = n; j > 0; j--) { self.moveBy(0,i); self.moveBy(i,0); self.moveBy(0,-i); self.moveBy(-i,0); }}}} </script> </head> <body> <form> <a href="javascript:tremer(20);">tremer</a> </form> </body> </html>

5. Abrir um pop up:


<html> <head> <title>Untitled</title> <script> function Openjanela(url_pop){ var PopWidth=700; var PopHeight=600; var PopLeft=0; var PopTop=0; Dk=window.open(url_pop,'Dk','toolbar=no,status=no,menubar=no,loc ation=no,directories=no,resizable=yes,scrollbars=yes,width='+Pop Width+',height='+PopHeight+',top='+PopTop+',left='+PopLeft); Dk.focus(); } </script> </head> <body> <form> <input type="text" size=50 name="caminho" id="caminho"> <input type="button" name="btabrir" value="Abrir" onclick="Openjanela(document.getElementById('caminho').value);"> </form> </body> </html>

Vous aimerez peut-être aussi