JavaScript
Transcrição
JavaScript
script ; <script type="text/javascript"> alert("Das ist eine JavaScript Meldung."); </script> body head body <html><head><title>JavaScript Alert</title></head> <body> <p>Das ist ein Absatz.</p> <script type="text/javascript"> alert("Das ist die JavaScript Alert-Box."); </script> </body> </html> <html><head> <script type="text/javascript"> function message() { alert("Das ist die JavaScript Alert-Box."); } </script> </head> <body onload="message()"> <p>Das ist ein Absatz.</p> </body> </html> <html> <head> <script type="text/javascript" src="alertbox.js"></script> </head> <body> <p>Das ist ein Absatz.</p> <script type="text/javascript"> <!-messageanzeigen(); //--> </script> </body> </html> function messageanzeigen() { alert("Das ist die JavaScript Alert-Box."); } <script type="text/javascript"> <!-document.write("Hallo Schwiiz!"); //--> </script> A a <script type="text/javascript"> // Write a heading document.write("<h1>Überschrift 1</h1>"); </script> /* */ <script type="text/javascript"> /* Jetzt schreibe ich… …zwei Überschriften */ document.write("<h1> Überschrift 1</h1>"); document.write("<h2> Überschrift 2</h2>"); </script> a = 7; b = 8; c = a+b; document.write(c); document.write alert document.write("Das ist mein langer Texxxxxxxxt…"); alert("Der Text in einer Alert Box"); prompt() <script type="text/javascript"> Frage="Das Wetter ist heute..."; DieEingabe=prompt(Frage,"schön!"); document.write("<b>Frage: </b>"+ Frage + "<br><b>Antwort:</b> " + DieEingabe); </script> BESTÄTIGUNG <html><head> <script type="text/javascript"> function bestaetigung() { var r=confirm("Drück einen Knopf"); if (r==true) { alert("Du hast dich für OK entschieden!"); } else { alert("Wieso Cancel?!"); } } </script> </head> <body> <input type="button" onclick="bestaetigung()" value="Entscheide dich für…" /> </body></html> <script type="text/javascript"> a = 12; b = 5; document.write("a:" + a + " ,b: " + b + "<br>"); // Ausgabe der Zahlen document.write(a + b + " :Addition<br>"); // Addition document.write(a - b + " :Subtraktion<br>"); // Subtraktion document.write(a * b + " :Multiplikation<br>"); // Multiplikation document.write(a / b + " :Division<br>"); // Division document.write(a % b + " : Modulo<br>"); // Modulo a++; document.write(a + " :Inkrement<br>"); // Inkrement b--; document.write(b + " :Dekrement<br>"); // Dekrement </script> == != > >= < <= ist gleich ist ungleich grösser als grösser oder gleich als kleiner als kleiner oder gleich als if (alter<18) document.write("Es gibt keinen Schnaps. Sorry!"); && || ! und oder nicht if (alter>=6 && alter <=18) document.write("Berechtigt für das Kinderabo"); if <script type="text/javascript"> zahl1 = 71; zahl2 = 70; if (zahl1>zahl2) { document.write("Zahl1: " + zahl1 + "<br>"); document.write("Zahl2: " + zahl2 + "<br>"); document.write(zahl1 + " ist grösser als " + zahl2); } else if (zahl1<zahl2) { document.write(zahl1 + " ist kleiner als " + zahl2); } else { document.write(zahl1 + " ist gleich " + zahl2); } </script> <script type="text/javascript"> a=12; b=5; c="Zürich"; d="Zuerich"; alert(c == d); // gleich alert(c != d); // ungleich alert(a <= b); // kleiner gleich alert(a < b); // kleiner alert(a >= b); // grösser gleich alert(a > b); // grösser </script> <script type="text/javascript"> <!— // for schleife wird 10x durchlaufen for (i=1; i<=10; i++) { document.write(i + ","); } // --> </script> <html><head> <script type="text/javascript"> function zeigemeldung() { alert("Hallo Schwiiz!"); } </script> </head> <body> <form> <input type="button" value="Klick mich!" onclick="zeigemeldung()" /> </form> </body></html> <html><head> <script type="text/javascript"> function rechne(a,b) { return a*b; } </script> </head> <body> <script type="text/javascript"> document.write("Das Resultat ist: " + rechne(4,7)); </script> </body></html> <a href="http://www.htmlkurs.ch" onmouseover="alert('Super Webseite ;-)');return false">www.htmlkurs.ch</a>