Java Script Displaying message
Content on Web Page • Static content • Dynamic content- Data Driven – Data • Processed Data • User Generated
Methods • Internal – JavaScript (JS) code written within HTML file • External – JavaScript(JS) code written in separate JS file – External JS file linked to HTML file
Internal-Code embedded within HTML • In HTML File –innerHtml <p id="para"> </p> <script> document.getElementById("para").innerHTML = "Hello World"; </script>
Code to link External JS file • In HTML File <script language="javascript" src="myscript.js"> </script>
External- Code written in JS file • In separate JS File document.write(); function f1() { document.write("Hello World"); }
External- Code written in JS file • In JS File window.alert(); function f2() { window.alert("Hello World"); }
JS within HTML document.write(); • Existing content on page is removed. • New Page with only the message on document.write command is printed. window.alert(); • Existing content on page is not removed. • An alert window appears on the existing window with the message on window.alert command printed on it.
External- Code written in JS file • In JS File console.log(); - writes to the console not the web page window. function f2() { console.log("Hello World!); }
Displaying message in JS on web page https://www.codewizacademy.com https://www.facebook.com/codewizacademy/ https://www.instagram.com/codewizacademy/

Displaying message on web page in Javascript

  • 1.
  • 2.
    Content on WebPage • Static content • Dynamic content- Data Driven – Data • Processed Data • User Generated
  • 3.
    Methods • Internal – JavaScript(JS) code written within HTML file • External – JavaScript(JS) code written in separate JS file – External JS file linked to HTML file
  • 4.
    Internal-Code embedded withinHTML • In HTML File –innerHtml <p id="para"> </p> <script> document.getElementById("para").innerHTML = "Hello World"; </script>
  • 5.
    Code to linkExternal JS file • In HTML File <script language="javascript" src="myscript.js"> </script>
  • 6.
    External- Code writtenin JS file • In separate JS File document.write(); function f1() { document.write("Hello World"); }
  • 7.
    External- Code writtenin JS file • In JS File window.alert(); function f2() { window.alert("Hello World"); }
  • 8.
    JS within HTML document.write(); •Existing content on page is removed. • New Page with only the message on document.write command is printed. window.alert(); • Existing content on page is not removed. • An alert window appears on the existing window with the message on window.alert command printed on it.
  • 9.
    External- Code writtenin JS file • In JS File console.log(); - writes to the console not the web page window. function f2() { console.log("Hello World!); }
  • 10.
    Displaying message inJS on web page https://www.codewizacademy.com https://www.facebook.com/codewizacademy/ https://www.instagram.com/codewizacademy/