JavaScript HTML DOM Events

When an HTML event occurs, HTML DOM allows JavaScript to respond accordingly. Some of these HTML events are: Onclick Occurrence: when an element is clicked. Ondblclick Occurrence: when an element is double-clicked. Onfocus Occurrence: when an element gets focus such as button, input, textarea, etc. Onblur Occurrence: when form loses the focus from an element. … Read more

JavaScript Deleting Cookies

Javascript facilitates multiple ways of deleting cookies. These are as follows: 1. Delete the cookie by using the expire attribute document.cookie = ‘name=Mahesh; expires=Sun, 19 May 2019 18:04:55 UTC’ 2. Delete the cookie by using the max-age attribute document.cookie = ‘name=Vishal; max-age=7200’ 3. Delete cookie explicitly by using a web browser Example: <!DOCTYPE html> <html> … Read more

JavaScript Cookie with multiple Name

In order to store multiple name-value pairs of cookies in javascript, the custom object must be serialized in a JSON string which is then parsed and stored in a cookie. A separate cookie can also be used for each name-value pair. Example: <!DOCTYPE html> <html> <head> </head> <body> Username: <input type=”text” id=”name”><br> Mail_ID: <input type=”email” … Read more

JavaScript Cookie Attributes

To enhance the functionality of cookies, some optional attributes may be used in Javascript. expires: Used to maintain the state of a cookie up to the specified date and time. document.cookie = ‘name=Jai; expires=Sun, 19 May 2019 18:04:55 UTC’ max-age: Used to maintain the state of a cookie up to the specified time in seconds. … Read more

JavaScript Abstraction

Abstraction is a way of hiding complexity. The JavaScript Data Abstraction feature is used for hiding internal details and showing the essential features of the object only. Note: We can not instantiate the Abstract class. Example: <!DOCTYPE html> <html> <body> <script> function Student() { this.Name=”Name”; throw new Error(“You cannot create an instance of Abstract Class”); … Read more