reading-notes


Project maintained by Razan-am Hosted on GitHub Pages — Theme by mattgraham

JAVASCRIPT

  1. How to write a script for a web page

There is three languages that are used to create web pages: HTML, CSS, and JavaScript.

With keeping the three languages in separate files, HTML page is linking to CSS and JavaScript files.Each language forms a different purpose.

These three layers form the basis of a popular approach to building web pages called progressive enhancement.

  1. CREATING A BASIC JAVASCRIPT

JavaScript is written in plain text, just like HTML and CSS,so you do not need any new tools to write a script.And to link it with the HTML :

  1. Create a folder to put the javascript file into it Ex; add-content . j s
  2. Use the HTML <script> element to tell the browser it is coming across a script.

<body>

<hl>Constructive &amp ; Co. </ hl>

<script src="js/ add-content.js"></ script>

<p>For all orders and i nquiries please cal l

<em>SSS-3344</ em></ p>

</ body>

  1. Applying objects and methods

It will be applied using document.write(object) its usually work with the conditions command.

JAVASCRIPT RUNS WHERE IT IS FOUND IN THE HTML

Example of the Javascript commands: var today= new Date(); var hourNow = today.getHours(); var greeting; if (hourNow > 18) { greeting= ‘Good evening!’; else if (hourNow > 12) { greeting = ‘ Good afternoon!’; else if (hourNow > 0) { greeting = ‘Good morni ng!’; else { greeting = ‘Welcome! ‘ ; document .write( ‘ <h3>’ +greeting + ‘ </ h3> ‘);

  1. Reading and writting JavaScript.

For example: var variable name = ‘variable value’; var age = ‘35’;

For exampels : var price = 5; var quantity = 14;

For example : var username = ‘Molly’; var message = ‘See our upcoming range’;

For exampel: var title = “Molly’s Special Offers” ; var message = ‘<a href="sale .html">25% offl</a>’

For exampel: var i nStock = true; var shipping = = false;

For exampel: var price = 5; var quantity = 14; var total = price * quantity;

References:

@Jon Duckett/JAVASCRIPT