web 1.0 in javascript

Web 1.0 was the era of static HTML websites, which primarily comprised of plain text, images, and hyperlinks. JavaScript wasn't initially intended for web development in the early days, but gradually it became popular for adding some basic interactivity to web pages.

Here's an example of how to create a simple web page in Web 1.0 using JavaScript:

<!DOCTYPE html>
<html>
  <head>
    <title>My First Web Page</title>
  </head>
  <body>
    <h1>Welcome to My Web Page</h1>
    <p>This is a paragraph of text.</p>
    <button onclick="alert('Hello, world!')">Click me</button>

    <script>
      // This is a JavaScript function that changes the text of the paragraph
      function changeText() {
        document.querySelector('p').textContent = 'New text!';
      }
    </script>
  </body>
</html>
452 chars
19 lines

In this example, we use HTML to define the basic structure of the web page, such as the page title, headings, paragraphs, and a button. The onclick attribute of the button is set to a JavaScript function that displays an alert dialog box when clicked.

The <script> tag is used to embed JavaScript code into the HTML page. In this example, we define a function changeText() that selects the first <p> element on the page using document.querySelector() and changes its content using .textContent.

This is a very basic example of how JavaScript can be used in Web 1.0 development. However, as web development progressed, JavaScript became much more powerful and evolved into a key technology for building interactive and dynamic web applications.

gistlibby LogSnag