Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.

Similar presentations


Presentation on theme: "JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted."— Presentation transcript:

1 JavaScript Introduction

2  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted into an HTML page  JavaScript is an open scripting language that anyone can use without purchasing a license  JavaScript is supported by all major browsers like Netscape and Internet Explorer

3  How Does it Work? When a JavaScript is inserted into an HTML document, the Internet browser will read the HTML and interpret the JavaScript. The JavaScript can be executed immediately or when some event occurs.

4 What can a JavaScript Do?  It can enhance the dynamics and interactive features of your page by allowing you to perform calculations  check forms  write interactive games  add special effects  customize graphics selections

5 What can a JavaScript Do?  JavaScript gives HTML designers a programming tool. JavaScript can put dynamic text into an HTML page. For Example, A JavaScript statement document.write(" " + name + " ") can write a variable text into the display of an HTML page, just like the static HTML text: Bill Gates does.

6  JavaScript can react to events. A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element.  JavaScript can read and write HTML elements  JavaScript can be used to validate data. in a form before it is submitted to a server. This function is particularly well suited to save the server from extra processing.

7 What's the difference between JavaScript and Java? The 2 languages have almost nothing in common except for the name. The 2 languages have almost nothing in common except for the name.

8  JavaScript Introduction tag: The primary method of including JavaScript within HTML is by using the tag. To specify scripting language name we have to use “language attribute” with tag. For example, tag: The primary method of including JavaScript within HTML is by using the tag. To specify scripting language name we have to use “language attribute” with tag. For example, indicates JavaScript indicates JavaScript indicates VBScript indicates VBScript

9 First JavaScript Program <html><head><title>JavaScriptTestProgram</title></head><body> document.write("Hi")</script></body></html>

10 JavaScript Test Program document.write("Hi")

11 How to Handle Older Browsers (or Browser that does not support JavaScript) Older browsers that do not support scripts will display the script as page content. To prevent them from doing this, you can use the HTML comment tag: The two forward slashes in front of the end of comment line (//) are a JavaScript comment symbol, and prevent the JavaScript from trying to compile the line.

12 Including HTML tags within JavaScript JavaScript Test Program document.write(" How R U? ")

13 Execution Order JavaScript Test Program First Time alert("1");

14 Scond Time alert("2"); Third Time alert("3");

15 Declaring & Calling Functions JavaScript Test Program function test() { alert("Function Executed"); }

16 test();

17 How to Run an External JavaScript Sometimes you might want to run the same script on several pages, without writing the script on each and every page. To simplify this you can write a script in an external file, and save it with a.js file extension, like this: document.write("This script is external"); Save the external file as ext.js.

18 Note: The external script cannot contain the tag Now you can call this script, using the "src" attribute, from any of your pages:

19 confirm box var name = confirm("Press a button") if (name == true) { document.write("You pressed OK") } else { document.write("You pressed Cancel") }

20 Input Box var name = prompt("Enter your name","") if (name != "") { document.write("Hello " + name) }

21 Opening a new Window function openwindow() { window.open("C:/Pushpal/JavaScriptStudy /script5.html") //window.open("http://www.yahoo.com") }


Download ppt "JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted."

Similar presentations


Ads by Google