Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaScript: How To? B. Ramamurthy.

Similar presentations


Presentation on theme: "JavaScript: How To? B. Ramamurthy."— Presentation transcript:

1 JavaScript: How To? B. Ramamurthy

2 Structure – Style -- Interaction
HTML provides structure CSS provides style Javascript (script) provides control for interaction and operations

3 Simple JS <!DOCTYPE html> <html> <head> <title> My first JavaScript </title> </head> <body> <h1> <script> document.write(“Hello, World!”); </script> </h1> </body> </html>

4 JS functions A function consists of function followed by the name of the function The statement that make up the function go next within curly brackets Example: function saySomething() { alert(“ We are getting ready for the exam 1”); }

5 Moving JS to an external file
Similar to how we separated style elements in css file, behavioral elements can be moved to an external js file.

6 HTML with External File JS
<!DOCTYPE html> <html> <head> <title> My second JavaScript </title> <script src=“script2.js”></script> </head> <body> <h1 id=“helloMessage”> </h1> </body> </html>

7 JS file window.onload = writeMessage; function writeMessage(){ document.getElementById(helloMessage).innerHTML = “Hello, World!”; }

8 Basic Elements of a web page
Web browser Firefox, Safari .html file .css file displays interprets image and audio files .js Prepare/edit files


Download ppt "JavaScript: How To? B. Ramamurthy."

Similar presentations


Ads by Google