| | |
| | | </table> |
| | | </section> |
| | | <section> |
| | | <pre> |
| | | <code class="html" data-trim data-line-numbers> |
| | | <script type="text/template"> |
| | | <!DOCTYPE html> |
| | | <html lang="de"> |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | </head> |
| | | <body> |
| | | <!-- code --> |
| | | </body> |
| | | </html> |
| | | </script> |
| | | </code> |
| | | </pre> |
| | | </section> |
| | | <section> |
| | | <p>Code wird zwischen <code>script</code>-Tags geschrieben</p> |
| | | <pre> |
| | | <code class="html" data-trim data-line-numbers> |
| | | <script> |
| | | ... |
| | | </script> |
| | | <!DOCTYPE html> |
| | | <html lang="de"> |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | </head> |
| | | <body> |
| | | <script>// code</script> |
| | | </body> |
| | | </html> |
| | | </code> |
| | | </pre> |
| | | </section> |
| | |
| | | </pre> |
| | | </section> |
| | | </section> |
| | | <section> |
| | | <section> |
| | | <h2>Auslagern in verschiedene Dateien</h2> |
| | | </section> |
| | | <section> |
| | | <pre> |
| | | <code class="html" data-trim data-line-numbers> |
| | | <!DOCTYPE html> |
| | | <html> |
| | | <head> |
| | | <!-- CSS --> |
| | | <link href="styles.css" rel="stylesheet"> |
| | | </head> |
| | | <body> |
| | | <!-- JS --> |
| | | <script src="index.js"></script> |
| | | </body> |
| | | </html> |
| | | </code> |
| | | </pre> |
| | | </section> |
| | | <section> |
| | | <p>Parsen eines HTML-Dokuments</p> |
| | | <pre> |
| | | <code class="html" data-trim data-line-numbers="1|2|3|4|5|6|7|8|9|10"> |
| | | <script type="text/template"> |
| | | <!DOCTYPE html> |
| | | <html lang="de"> |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>Coole Seite 😀</title> |
| | | </head> |
| | | <body> |
| | | <div>Ganz langer Text</div> |
| | | </body> |
| | | </html> |
| | | </script> |
| | | </code> |
| | | </pre> |
| | | </section> |
| | | <section> |
| | | <p>Verschiedene Varianten, JavaScript erst am Ende auszuführen</p> |
| | | <p>Damals mit jQuery:</p> |
| | | <pre> |
| | | <code class="html" data-trim data-line-numbers> |
| | | <!DOCTYPE html> |
| | | <html> |
| | | <head> |
| | | <script> |
| | | $(document).ready((event) => { |
| | | const element = document.querySelector("#hello"); |
| | | }); |
| | | </script> |
| | | </head> |
| | | <body> |
| | | <div id="hello">Hello World!</div> |
| | | </body> |
| | | </html> |
| | | </code> |
| | | </pre> |
| | | </section> |
| | | <section> |
| | | <p><code>script</code>-Tag am Ende</p> |
| | | <pre> |
| | | <code class="html" data-trim data-line-numbers> |
| | | <!DOCTYPE html> |
| | | <html> |
| | | <head> |
| | | </head> |
| | | <body> |
| | | <div>Hello World!</div> |
| | | ... |
| | | <script src="index.js"></script> |
| | | </body> |
| | | </html> |
| | | </code> |
| | | </pre> |
| | | </section> |
| | | <section> |
| | | <p>Event-basiert, z.B. per DOMContentLoaded</p> |
| | | <pre> |
| | | <code class="html" data-trim data-line-numbers> |
| | | <!DOCTYPE html> |
| | | <html> |
| | | <head> |
| | | <script> |
| | | document.addEventListener("DOMContentLoaded", (event) => { |
| | | // wird ausgeführt, sobald das Dokument geparst wurde |
| | | const element = document.querySelector("#hello"); |
| | | }); |
| | | </script> |
| | | </head> |
| | | <body> |
| | | <div id="hello">Hello World!</div> |
| | | </body> |
| | | </html> |
| | | </code> |
| | | </pre> |
| | | </section> |
| | | <section> |
| | | <p>Moderne Variante</p> |
| | | <pre> |
| | | <code class="html" data-trim data-line-numbers> |
| | | <script src="index.js" defer></script> |
| | | </code> |
| | | </pre> |
| | | </section> |
| | | <section> |
| | | <h2><code>document</code>-Operationen</h2> |
| | | <pre> |
| | | <code class="js" data-trim data-line-numbers> |
| | | document.open(); |
| | | document.write("<div>Booo!</div>"); |
| | | document.close(); |
| | | </code> |
| | | </pre> |
| | | </section> |
| | | <section> |
| | | <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/write"> |
| | | <img data-src="/assets/images/document.write.jpg"> |
| | | </a> |
| | | </section> |
| | | <section> |
| | | <pre> |
| | | <code class="html" data-trim data-line-numbers> |
| | | <body> |
| | | <script>document.write("<p>Dies ist ein Text.</p>")</script> |
| | | <button>Dunkle Magie</button> |
| | | <script> |
| | | const button = document.querySelector("button"); |
| | | |
| | | button.addEventListener("click", () => { |
| | | document.write("Und pfutsch!"); |
| | | }); |
| | | </script> |
| | | </body> |
| | | </code> |
| | | </pre> |
| | | </section> |
| | | </section> |
| | | <section> |
| | | <section> |
| | | <h2>HTTP-Protokoll</h2> |
| | | </section> |
| | | <section> |
| | | <img data-src="/assets/images/osi-model.jpg"> |
| | | </section> |
| | | <section> |
| | | <ul> |
| | | <li>Befindet sich auf den OSI-Schichten 5, 6 und 7</li> |
| | | <li>Basiert auf dem Anfrage-Antwort-Prinzip</li> |
| | | <li>Basiert auf reinem Text</li> |
| | | </ul> |
| | | </section> |
| | | <section> |
| | | <p><code>npm install http-server</code></p> |
| | | <p><code>npx http-server --port 3000</code></p> |
| | | </section> |
| | | </section> |
| | | </div> |
| | | </div> |
| | | |