Let’s begin with some of the basic and core concepts of javscript.
<p onclick=”alert(‘hi’)”>Hello</p> : In this example event used is click. Whenever user will click on the paragraph one dialog box comes with hi written on it.
alert():The function is used to display the text in a dialog box pop up on the screen.
Here is the ouput of above code.
• 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. Otherwise it will hold the screen.
• 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.
• Prompt Box
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.
Document Object Model (DOM)
DOM is a programming interface (API) for representing and interacting with HTML, XHTML and XML documents. It organize the elements of the document in tree structure (DOM tree) and in the DOM tree, all elements of the document are defined as objects (tree nodes) which have properties and methods.
DOM objects: window, document, history, location.
DOM methods: appendChild, createElement, reload, removeNode.
DOM properties: appName, appVersion, href.
Browser Object Model (BOM)
Unlike DOM, there is no standard defined for BOM, hence different browsers implement it in different ways. Typically, the collection of browser objects is collectively known as the Browser Object Model.
BOM main task is to manage browser windows and enable communication between the windows. Each HTML page which is loaded into a browser window becomes a Document object.
BOM objects : document, location, history, navigator,screen,frames.
Thanks for reading!!