exercicios javascript

2
Exemplos Programação Client Side - Javascript CURSO: Técnico/a de Informática - Instalação e Gestão de Redes Ano Lectivo: 2010 / 2011 Disciplina: Servidores WEB Pólo: Castelo Branco Nome do Formador: Luís Alves 1. Chamar função Javascript a partir de um link: <html> <body> <a href="javascript:alert(‘Executar uma função a partir de um link')">clique aqui para executar</a> </body> </html> 2. Informações 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. Informações da resolução <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>

Upload: luis-alves

Post on 25-Apr-2015

74 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Exercicios Javascript

Exemplos Programação Client Side - Javascript

CURSO: Técnico/a de Informática - Instalação e Gestão de Redes

Ano Lectivo: 2010 / 2011

Disciplina: Servidores WEB Pólo: Castelo Branco

Nome do Formador: Luís Alves

1. Chamar função Javascript a partir de um link:

<html>

<body>

<a href="javascript:alert(‘Executar uma função a partir de

um link')">clique aqui para executar</a>

</body>

</html>

2. Informações 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. Informações da resolução

<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>

Page 2: Exercicios Javascript

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>