Les 2 Javascript

271 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
271
On SlideShare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Les 2 Javascript

  1. 1. Javascript 2<br />IF-Else / Switch / PopUp / Functions<br />
  2. 2. IF - Else<br /><ul><li>if statement- use this statement to execute some code only if a specified condition is true
  3. 3. if...else statement- use this statement to execute some code if the condition is true and another code if the condition is false
  4. 4. if...else if....else statement- use this statement to select one of many blocks of code to be executed</li></ul>if (time < 12)<br /> {<br />document.write("Goede Morgen");<br /> }<br />else<br /> {<br />document.write("Goede Middag");<br /> }<br />
  5. 5. IF - Else<br />
  6. 6. IF - Else<br />
  7. 7. Switch<br />switch(n){case 1:  execute code block 1  break;case 2:  execute code block 2  break;default:  code to be executed if n is different from case 1 and 2}<br />
  8. 8. Switch<br />
  9. 9. Pop-Up<br />Alert<br />alert(“tekst");<br />
  10. 10. Pop-Up<br />Confirm<br />
  11. 11. Pop-Up<br />Prompt<br />prompt(“text","defaultvalue");<br />
  12. 12. Functions<br />functionfunctionname(var1,var2,...,varX){some code}<br />The parameters var1, var2, etc. are variables or values passed into the function. The { and the } defines the start and end of the function.<br />Note: A function with no parameters must include the parentheses () after the function name.<br />Note: Do not forget about the importance of capitals in JavaScript! The word function must be written in lowercase letters, otherwise a JavaScript error occurs! Also note that you must call a function with the exact same capitals as in the function name.<br />
  13. 13. Functions<br />Return<br />
  14. 14. Functions<br />Browserdetectie<br />
  15. 15. Functions<br />Browserdetectie 2<br />
  16. 16. Opdracht !<br />Experimenteren met de code !<br />

×