0% found this document useful (0 votes)
14 views

Chapter 2WP

Web development
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Chapter 2WP

Web development
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

CHAPTER 2

JAVA SCRIPT & HTML DOCUMENTS

UNIT 1
• JavaScript (js) is a light-weight object-oriented programming language
which is used by several websites for scripting the webpages.
• It is an interpreted, full-fledged programming language that enables
dynamic interactivity on websites when applied to an HTML
document.
• The JavaScript Translator (embedded in the browser) is responsible
for translating the JavaScript code for the web browser.
• It turns static HTML web pages into interactive web pages by
dynamically updating content, validating form data, controlling
multimedia, animate images etc
• It is a case-sensitive language.
• JavaScript History
• In early 1995, Brendan Eich from Netscape designed and implemented
a new language for non-java programmers to give newly added Java
support in Netscape navigator.
• It was initially named Mocha, then LiveScript, and finally JavaScript.
• Application of JavaScript
• JavaScript is used to create interactive websites. It is mainly used for:
• Client-side validation,
• Dynamic drop-down menus,
• Displaying date and time,
• Displaying pop-up windows and dialog boxes (like an alert dialog box,
confirm dialog box and prompt dialog box),
• Setup JavaScript Development Environment
• Here, we are going to use JavaScript in developing a web application.
So, we must have at least two things, a browser, and an editor to write
the JavaScript code.
• The followings are some of the well-known JavaScript editors:
• Visual Studio Code (Free, cross-platform)
• Eclipse (Free, cross-platform)
• Atom (Free, cross-platform)
• Notepad++ (Free, Windows)
• Code Lobster (Free, cross-platform)
• WebStorm (Paid, cross-platform)
• Online Editors for JavaScript
• Use the online editor to quickly execute the JavaScript code without
any installation. The followings are free online editors:
• jsfiddle.net
• jsbin.com
• playcode.io
• Browser Object Model (BOM)
• The Browser Object Model (BOM) is used to interact with the
browser.
• The default object of browser is window means you can call all the
functions of window by specifying window or directly. For example:
Window Object

The window object represents a window in browser. An object of window


is created automatically by the browser.
Window is the object of browser, it is not the object of javascript. The
javascript objects are string, array, date etc.
• JavaScript History Object
• The JavaScript history object represents an array of URLs visited by
the user. By using this object, you can load previous, forward or any
particular page.
• The history object is the window property, so it can be accessed by:
• window.history
•Document Object Model
• The document object represents the whole html document.
• When html document is loaded in the browser, it becomes a document
object. It is the root element that represents the html document.
• The DOM represents an HTML document as a tree of nodes.
• The DOM provides functions that allow you to add, remove, and
modify parts of the document effectively.
• Javascript - document.getElementById() method
• The document.getElementById() method returns the element of
specified id.
• Traversing the DOM
• Traversing the DOM (Document Object Model) refers to the process of
navigating through the different elements in an HTML or XML
document using JavaScript.
• The DOM is a hierarchical tree-like structure that represents the
different elements in a web page, and each element is represented as a
node in the tree.
• Traversing the DOM involves moving up and down the tree, accessing
and manipulating different elements in the document, and navigating
between parent and child nodes.
• JavaScript Form Validation
• It is important to validate the form submitted by the user because it can
have inappropriate values. So, validation is must to authenticate user.
•JavaScript Events
• The change in the state of an object is known as an Event.
• In html, there are various events which represents that some activity is
performed by the user or by the browser.
• When javascript code is included in HTML, js react over these events
and allow the execution.
• This process of reacting over the events is called Event Handling.
Thus, js handles the HTML events via Event Handlers.

You might also like