JAVASCRIPT-WEB
LATJS01.HTML <script> alert("Hello word"); var x = 5; var nama = "Desrizal"; document.write(nama); </script>
LATJS02.HTML <script> var nama="Syaiful Anwar"; var x = 4; var y = 2; z = x + y; alert(z); alert(nama); </script>
LATJS03.HTML <script> for (i = 1; i <= 10; i++) { document.write(i); } </script>
LATJS04.HTML <script> var i=1; while(i<=5) { document.write("Nomor : "+i +"<br />"); i++; } </script>
LATJS05.HTML <script> function tes() { document.write("Hello World!"); } function kalikan(x,y) { z = x * y; // alert("Hasil kali "+x+" * "+y+" = "+z); document.write("Hasil kali "+x+" * "+y+" = "+z); } //untuk menjalankan fungsi, cukup tulis namafungsi tes(); kalikan(5,3); </script>
LATJS06.HTML <html> <body> <a href=”http://www.google.com” onclick=”alert(‘hello’)”>google</a> </body> </html>
LATJS07.HTML <script> function inform(){ alert("Hai anda mengklik saya") } </script> <form> <input type="button" name="test" value="Click me" onclick="inform()"> </form>
LATJS08.HTML <html> <body> <form name="go"> <input type="radio" name="C1" onclick="document.bgColor='lightblue'"> <input type="radio" name="C1" onclick="document.bgColor='lightyellow'"> <input type="radio" name="C1" onclick="document.bgColor='lightgreen'"> </form> </body> </html>
LATJS09.HTML <html> <head> <title>Body onload example</title> </head> <body onload="alert('Halaman ini telah selesai di loading')"> Welcome to my page </body> </html>
LATJS10.HTML <html> <body> <table> <tr onmouseover="this.bgColor='lightblue'" onmouseout="this.bgColor='#efefef'" bgcolor="#efefef"> <td>Baris pertama</td> </tr> <tr> <td>Baris kedua</td> </body> </html>
LATJS11.HTML <script> var message="Selamat datang di BSI!" var format=message.toUpperCase() var size=1 for (i=0;i<message.length;i++) { document.write(format.charAt(i).fontsize(size).bold()) if (size<7){ size++ } else { size=1 } } </script>
LATJS12.HTML <script type="text/javascript"> var x=window.confirm("Apakah anda baik-baik saja?") if (x) window.alert("Good!") else window.alert("Too bad") </script>
LATJS13.HTML <script type="text/javascript"> var y=window.prompt("Masukkan nama anda") window.alert(y) </script>
LATJS14.HTML <html> <head> <title>Menampilkan pesan Warning</title> <script language="javascript"> var pesan = "Dilarang Masuk selain Petugas!"; function warning() { alert(pesan); } function password() var passwd = prompt("Masukkan Password"); if (passwd != 'petugas') alert('Gagal'); else alert('Sukses'); </script> </head> <body onload="warning();"> <p><b>TEMPAT RAHASIA</b></p> <p>Sekali lagi saya tegaskan jangan memasuki area ini selain petugas. BERBAHAYA!!!</p> <a href="javascript: password();">Masuk =></a> </body> </html>