cs142 section javascript mischief
play

CS142: Section Javascript Mischief Elie Bursztein - 16th Jan. 2008 - PowerPoint PPT Presentation

CS142: Section Javascript Mischief Elie Bursztein - 16th Jan. 2008 Elie Bursztein CS142: Section Javascript Mischief 1 / 10 HTML (Again) Elie Bursztein CS142: Section Javascript Mischief 2 / 10 HTML (Again) < body > Elie


  1. CS142: Section Javascript Mischief Elie Bursztein - 16th Jan. 2008 Elie Bursztein CS142: Section Javascript Mischief 1 / 10

  2. HTML (Again) Elie Bursztein CS142: Section Javascript Mischief 2 / 10

  3. HTML (Again) ◮ < body > Elie Bursztein CS142: Section Javascript Mischief 2 / 10

  4. HTML (Again) ◮ < body > ◮ < div > Elie Bursztein CS142: Section Javascript Mischief 2 / 10

  5. HTML (Again) ◮ < body > ◮ < div > ◮ < a > Elie Bursztein CS142: Section Javascript Mischief 2 / 10

  6. HTML (Again) ◮ < body > ◮ < div > ◮ < a > ◮ < ul > Elie Bursztein CS142: Section Javascript Mischief 2 / 10

  7. HTML (Again) ◮ < body > ◮ < div > ◮ < a > ◮ < ul > ◮ < li > Elie Bursztein CS142: Section Javascript Mischief 2 / 10

  8. Linking CSS to HTML elements How do you alter a specific HTML element with CSS ? Elie Bursztein CS142: Section Javascript Mischief 3 / 10

  9. Linking CSS to HTML elements How do you alter a specific HTML element with CSS ? ◮ tag Elie Bursztein CS142: Section Javascript Mischief 3 / 10

  10. Linking CSS to HTML elements How do you alter a specific HTML element with CSS ? ◮ tag ◮ class Elie Bursztein CS142: Section Javascript Mischief 3 / 10

  11. Linking CSS to HTML elements How do you alter a specific HTML element with CSS ? ◮ tag ◮ class ◮ id Elie Bursztein CS142: Section Javascript Mischief 3 / 10

  12. Example How do you color this link in red ? < a href=“#” class=“myclass” id=“myid” > someurl < /a > Elie Bursztein CS142: Section Javascript Mischief 4 / 10

  13. Example How do you color this link in red ? < a href=“#” class=“myclass” id=“myid” > someurl < /a > ◮ tag : a { color: red; } Elie Bursztein CS142: Section Javascript Mischief 4 / 10

  14. Example How do you color this link in red ? < a href=“#” class=“myclass” id=“myid” > someurl < /a > ◮ tag : a { color: red; } ◮ class : .myclass { color:#FF0000; } Elie Bursztein CS142: Section Javascript Mischief 4 / 10

  15. Example How do you color this link in red ? < a href=“#” class=“myclass” id=“myid” > someurl < /a > ◮ tag : a { color: red; } ◮ class : .myclass { color:#FF0000; } ◮ id : #myid { color:rgb(255, 0, 0); } Elie Bursztein CS142: Section Javascript Mischief 4 / 10

  16. Linking Javascript and HTML How do you alter a specific HTML element with Javascript ? ◮ Each element is an object. ◮ Javascript allows to select an element by its id. Elie Bursztein CS142: Section Javascript Mischief 5 / 10

  17. Example How do you change this link href ? < a href=“#” class=“myclass” id=“myid” > someurl < /a > Elie Bursztein CS142: Section Javascript Mischief 6 / 10

  18. Example How do you change this link href ? < a href=“#” class=“myclass” id=“myid” > someurl < /a > ◮ v = document.getElementById(’myid’); Elie Bursztein CS142: Section Javascript Mischief 6 / 10

  19. Example How do you change this link href ? < a href=“#” class=“myclass” id=“myid” > someurl < /a > ◮ v = document.getElementById(’myid’); ◮ v.href = “http://mysite.com”; Elie Bursztein CS142: Section Javascript Mischief 6 / 10

  20. WebSite are event driven One of the key difference between a text and a page : Page reacts to user actions Elie Bursztein CS142: Section Javascript Mischief 7 / 10

  21. WebSite are event driven One of the key difference between a text and a page : Page reacts to user actions ◮ Click Elie Bursztein CS142: Section Javascript Mischief 7 / 10

  22. WebSite are event driven One of the key difference between a text and a page : Page reacts to user actions ◮ Click ◮ Submission Elie Bursztein CS142: Section Javascript Mischief 7 / 10

  23. WebSite are event driven One of the key difference between a text and a page : Page reacts to user actions ◮ Click ◮ Submission ◮ Inputs Elie Bursztein CS142: Section Javascript Mischief 7 / 10

  24. WebSite are event driven One of the key difference between a text and a page : Page reacts to user actions ◮ Click ◮ Submission ◮ Inputs ◮ Loading/Unloading Elie Bursztein CS142: Section Javascript Mischief 7 / 10

  25. WebSite are event driven One of the key difference between a text and a page : Page reacts to user actions ◮ Click ◮ Submission ◮ Inputs ◮ Loading/Unloading ◮ Focus/Unfocus Elie Bursztein CS142: Section Javascript Mischief 7 / 10

  26. Linking Event and Javascript How do you bind a Javascript function to an Event ? ◮ Most of HTML tags support action handlers. Elie Bursztein CS142: Section Javascript Mischief 8 / 10

  27. Linking Event and Javascript How do you bind a Javascript function to an Event ? ◮ Most of HTML tags support action handlers. ◮ We bind javascript function to these handlers. Elie Bursztein CS142: Section Javascript Mischief 8 / 10

  28. Some examples Here is some examples of handlers: Elie Bursztein CS142: Section Javascript Mischief 9 / 10

  29. Some examples Here is some examples of handlers: ◮ user click: < a onclick=“somefunction()” Elie Bursztein CS142: Section Javascript Mischief 9 / 10

  30. Some examples Here is some examples of handlers: ◮ user click: < a onclick=“somefunction()” ◮ mouse over: < a onmouseover=“somefunction()” Elie Bursztein CS142: Section Javascript Mischief 9 / 10

  31. Some examples Here is some examples of handlers: ◮ user click: < a onclick=“somefunction()” ◮ mouse over: < a onmouseover=“somefunction()” ◮ element loaded: < a onload=“somefunction()” Elie Bursztein CS142: Section Javascript Mischief 9 / 10

  32. Magic ? How do you make an element disappear ? Elie Bursztein CS142: Section Javascript Mischief 10 / 10

  33. Magic ? How do you make an element disappear ? ◮ visibility: visible or hidden Elie Bursztein CS142: Section Javascript Mischief 10 / 10

  34. Magic ? How do you make an element disappear ? ◮ visibility: visible or hidden ◮ display: block, inline, none Elie Bursztein CS142: Section Javascript Mischief 10 / 10

  35. Magic ? How do you make an element disappear ? ◮ visibility: visible or hidden ◮ display: block, inline, none Do you know the difference ? Elie Bursztein CS142: Section Javascript Mischief 10 / 10

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend