Web Development Articles - Page 501 of 1049

Higher-Order Arrow Functions in JavaScript.

AmitDiwan
Updated on 16-Jul-2020 13:40:12

374 Views

JavaScript treats functions as objects and allow us to pass functions as parameter to another function and even return functions from other functions. In JavaScript, the functions are first class functions i.e. we can store them in variable, objects and array. The higher order arrow functions can take function, return them or do both.Following is the code for higher order arrow functions in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,    .sample {       font-size: 18px;       ... Read More

JavaScript program to retrieve clients IP address

Shriansh Kumar
Updated on 08-Oct-2024 17:20:26

1K+ Views

Internet Protocol address, in short, IP address, is a unique address represented by a string of numbers that identifies a device on the internet or a local network. In JavaScript, we can retrieve a client's IP addresses using a 3rd parties API services such as ipify or ipapi. We can then further use this information to track user locations, personalize content based on the location, or implement security measures. Using "ipify" API To obtain the client's IP address, we will use a third−party API service (https://www.ipify.org/). We'll send a GET call to the "ipify" API using the $.getJSON() function to ... Read More

Disabling arrow key in text area using JavaScript.

AmitDiwan
Updated on 16-Jul-2020 13:35:40

322 Views

Following is the code for disabling arrow key in text area in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-weight: 500;       font-size: 18px;       color: blueviolet;    } Disabling arrow keys in a text area Hello world this is some sample text inside the text area element Disable arrows Click on the above button to disable scrolling using arrows in the above textArea    let ... Read More

Setting full screen iframe in JavaScript?

AmitDiwan
Updated on 16-Jul-2020 13:33:03

2K+ Views

Following is the code for setting full screen iframe in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-weight: 500;       font-size: 18px;       color: blueviolet;    }    .fullScreen {       width: 100vw;       height: 100vh;    } Setting full screen iframe Fullscreen Click on the above button to make the iframe go fullscreen    let BtnEle = document.querySelector(".Btn");    let frameEle = document.querySelector(".frame");    BtnEle.addEventListener("click", () => {       frameEle.className = "fullScreen";    }); OutputOn clicking the ‘Fullscreen’ button −

How to toggle a boolean using JavaScript?

AmitDiwan
Updated on 16-Aug-2023 15:08:11

6K+ Views

In this tutorial, we will learn how to toggle a boolean value in javascript. In addition to this, we will also learn how we can use it for various web application features that require toggling a certain piece of state or value. Toggling a boolean in JavaScript entails altering its value from true to false or vice versa. Toggling booleans can be helpful in a variety of situations, such as changing a boolean value to initiate an action or to toggle between states or the visibility of an element. Toggling can be implemented using different methods like the NOT operator, ... Read More

Creating auto-resize text area using JavaScript

AmitDiwan
Updated on 16-Aug-2023 15:05:39

959 Views

In this post, we are going to learn how to set up an auto−size text area in JavaScript. This text area will be able to change its height automatically depending on the content within it. Auto−size text in JavaScript is a helpful feature that can be used to edit multiple lines of text. The text can automatically change its height depending on the content inside it. The default behavior of textarea doesn’t allow this, but we can create it by using the input event listener over it. Let’s understand how to adjust the height of the text area element dynamically ... Read More

How to autofill a field in JavaScript same as another?

Disha Verma
Updated on 10-Mar-2025 15:46:21

1K+ Views

Automatically filling in a field in JavaScript is a common need in web forms, where one field copies the value from another. This feature eliminates the need to write the same information in one or more fields. This is useful in real-life scenarios, such as filling in the forms where the user has entered the permanent address and has to add a temporary address. If both the addresses are the same, using the autofilling feature, he can automatically copy the permanent address into the temporary address. This article explains how to create autofill features in JavaScript. Core Concept: Copying ... Read More

Location protocol Property in JavaScript

AmitDiwan
Updated on 16-Aug-2023 15:03:36

233 Views

This article will teach us how to use the Javascript location protocol properties to implement the web application's protocol. The read−only location.protocol property in javascript returns the protocol specified in the current webpage's URL. It offers details on the URL's protocol, including "http:", "https:", "file:", etc. Common protocol values that are utilised by numerous web apps include − http − It represents the Hypertext Transfer Protocol (HTTP). https − It represents the Hypertext Transfer Protocol Secure (HTTPS). file − It represents the File Transfer Protocol (FTP). ftp − It represents the File Transfer Protocol (FTP). data − It represents the data ... Read More

PreventDefault( ) vs Return false in JavaScript?

AmitDiwan
Updated on 16-Aug-2023 14:59:37

3K+ Views

In this post, we will discover how to use javascript's preventDefault and return false functions to override an event's default behaviour. The two most popular JavaScript methods for stopping an event's default behaviour are preventDefault() and return false. Let’s understand both of the concepts below − preventDefault() Return false The preventDefault() method is a function available on event objects in JavaScript Return false is not a function, but a javascript statement It helps to stop a certain event's default behaviour. It not only prevents the default behavior but also stops the event from ... Read More

Explain focus events in JavaScript

AmitDiwan
Updated on 16-Aug-2023 14:46:06

1K+ Views

The focus of items on a web page can be determined via focus events, which we will learn about in this article. The numerous browser−provided events that are triggered when an HTML element gains or loses attention are known as focus events in JavaScript. These occasions can be utilised in a number of contexts, for as in response to user actions like clicking on an input field. We can track when a web page element obtains or loses focus with the aid of focus events. There are three main focus events in JavaScript − Focus − This event gets ... Read More

Advertisements