JavaScript (JS) Basics

Slides:



Advertisements
Similar presentations
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Advertisements

آموزش طراحی وب سایت جلسه یازدهم – جاوا اسکریپت 2 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
Computer Science 103 Chapter 4 Advanced JavaScript.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Lesson 8 Creating Forms with JavaScript
آموزش طراحی وب سایت جلسه دهم – جاوا اسکریپت 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
CP476 Internet Computing JavaScript and HTML1 1.JavaScript Execution Environment The JavaScript Window object represents the window in which the browser.
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
JavaScript Part 1.
Intro to JavaScript. Use the tag to tell the browser you are writing JavaScript.
Using Client-Side Scripts to Enhance Web Applications 1.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
JavaScript - A Web Script Language Fred Durao
Button and Textbox. Input  Input objects are used to obtain input from the user viewing the webpage. They allow the user to interact with the Web. 
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
1 JavaScript
1 JavaScript 2 JavaScript. 2 Rollovers Most web page developers first use JavaScript for rollovers A rollover is a change in the appearance of an element.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
JavaScript Challenges Answers for challenges
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
Project 8: Reacting to Events Essentials for Design JavaScript Level One Michael Brooks.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
5 th and 4 th ed: some from chapters 9, 12, 13 SY306 Web and Databases for Cyber Operations Slide Set #8: Dynamic HTML.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
HTML DOM Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Popup Boxes.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
WEB SYSTEMS & TECHNOLOGY. Java Script  JavaScript created by Netscape  It is also client side programming  It can be use for client side checks.
JavaScript, Third Edition 1 SELECTION LIST Demo. JavaScript, Third Edition 2 Description This web page will edit the slection to ensure an option was.
Third lecture Event 27/2/2016 JavaScript Tutorial.
JavaScript and HTML Simple Event Handling 11-May-18.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Using JavaScript to Show an Alert
Pertemuan 7 JavaScript.
Web Development & Design Foundations with HTML5
Introduction to JavaScript Events
Web Development & Design Foundations with HTML5 7th Edition
WEB APPLICATION PROGRAMMING
JAVASCRIPTS AND HTML DOCUMENTS
JavaScript and HTML Simple Event Handling 19-Sep-18.
CHAPTER 7 JavaScripts & HTML Documents
My First Web Page document.write("" + Date() + ""); To insert.
JavaScript Defined General Syntax Body vs. Head Variables Math & Logic
CS105 Introduction to Computer Concepts
Web Programming– UFCFB Lecture 13
محمد احمدی نیا JavaScript محمد احمدی نیا
JavaScript and Ajax (JavaScript Events)
Barb Ericson Georgia Institute of Technology May 2006
CS105 Introduction to Computer Concepts JavaScript
JavaScript and HTML Simple Event Handling 26-Aug-19.
JavaScript and HTML Simple Event Handling 4-Oct-19.
Presentation transcript:

JavaScript (JS) Basics (Part - 3)

Pop Up Boxes JavaScript has three kind of popup boxes: Alert box Confirm box Prompt box.

Alert Box An alert box is often used if you want to make sure information comes through to the user. When an alert box pops up, the user will have to click "OK" to proceed.

Alert Box <html> <head> <script type="text/javascript"> function show_alert() { alert("I am an alert box!"); } </script> </head> <body> <input type="button“ onclick="show_alert()" value="Show alert box" /> </body> </html>

Confirm Box A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.

Confirm Box <html> <head> <script type="text/javascript"> function show_confirm() { r = confirm("Press a button"); if (r == true) { document.write("You pressed OK!"); } else { document.write("You pressed Cancel!"); } } </script> </head>

Confirm Box <body> <input type="button" onclick="show_confirm()" value="Show confirm box" /> </body> </html>

Prompt Box A prompt box is often used if you want the user to input a value before entering a page. When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value. If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null.

Prompt Box <html> <head> <script type="text/javascript"> function show_prompt() { name=prompt("Please enter your name","Harry Potter"); if (name != null && name != "") { document.write("Hello " + name + "! How are you today?"); } } </script> </head>

Prompt Box <body> <input type="button" onclick="show_prompt()" value="Show prompt box" /> </body> </html>

Events Events are actions that can be detected by JavaScript. More easily, event can be defined as something that can be done by the user By using JavaScript, we have the ability to create dynamic web pages (web pages that react or behave differently depending on user input). Every element on a web page has certain events which can trigger a JavaScript event. For example, we can use the onClick event of a button element to indicate that a function will run when a user clicks on the button. We define the events in the HTML tags.

Events Examples of events: A mouse click A web page or an image loading Mousing over a hot spot on the web page Selecting an input field in an HTML form Submitting an HTML form A keystroke

onLoad Event The onLoad event is triggered when the user enters the web page: <html> <head> <script type="text/javascript"> function message(){ alert("Loading..."); } </script> </head> <body onLoad="message()"> </body> </html>

onFocus & onMouseOver Event The onfocus event occurs when an object (button, textbox or any other HTML element) gets focus. onMouseOver event occurs when we move mouse over an object

onFocus Event <html> <head> <script type="text/javascript"> function message(){ alert("Type your name"); } </script> </head> <body> <form name="frm"> <input name="digit" type="text" onFocus="message()"> </form> </body> </html>