GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Main Page
  • Browse
  • Recent changes
  • Guided tours
  • Random
  • Help
  • Portal
  • Colloquium
  • News
  • Projects
  • Sandbox
  • Search
  • Donate
  • Create account

This view

  • Original page
  • New address

GeezerVison is showing en.wikiversity.org — JavaScript Programming/Introduction/Example Code - Wikiversity

< JavaScript Programming | Introduction

example.html

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="Cache-Control" content="no-cache">
  <meta http-equiv="Content-Security-Policy" content="script-src-elem 'unsafe-inline' 'self'">

  <title>Example</title>
  
  <!-- The following line loads the external script. -->
  <script defer src="example.js" async></script>

  <script>
    //script in head
    document.write("Hello Wikiversity!");
  </script>
</head>

<body>
  <noscript>Enable JavaScript to see web page content.</noscript>
  <p id="text"></p>
  <p id="html"></p>
  
  <script>
    //script in body
    window.alert("Hello Wikiversity!");
  </script>
</body>

</html>

example.js

//This script demonstrates JavaScript output five different ways.
//Two script blocks are in the HTML page. This script is external.

document.getElementById("text").innerText = "Hello Wikiversity!";
document.getElementById("html").innerHTML = "<strong>Hello Wikiversity!</strong>";
console.log("Hello Wikiversity!")
Retrieved from "https://en.wikiversity.org/w/index.php?title=JavaScript_Programming/Introduction/Example_Code&oldid=2307294"
Category:
  • JavaScript Programming
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.