Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Front End Technology Articles
Page 295 of 652
How to check a URL contains a hash or not using JavaScript?
To check whether a URL contains a hash (#) fragment or not in JavaScript, we can use the window.location.hash property. This property returns the hash portion of the URL, including the # symbol, or an empty string if no hash exists. What is a URL Hash? A URL hash is the part of a URL that comes after the # symbol. For example, in the URL https://example.com/page#section1, the hash is #section1. Hashes are commonly used for navigation within a single page or to reference specific sections of content. Syntax window.location.hash This property returns: ...
Read MoreHow to check an element with specific id exist using JavaScript?
In JavaScript, checking if an HTML element with a specific ID exists is a common task when manipulating the DOM. The document.getElementById() method returns the element if found, or null if not found. Syntax document.getElementById(id) document − The document object represents the HTML page loaded in the browser getElementById() − A method that searches for an element with the specified ID and returns it, or null if not found How It Works When document.getElementById() is called, it searches through the DOM tree to find an ...
Read MoreHow to serialize a cookie name-value pair into a Set Cookie header string in JavaScript?
The cookie allows us to store users' data in the web browser for quick response. For example, when a user opens the profile page in any web application, the web page receives the data from the server. The server also sends the cookies containing the data to store in the web browser. When a user goes on the profile page again, it fetches the data from the cookie rather than fetching it from the server to load the webpage quickly. To get data browser looks in the cookie first, and if it doesn't find data stored in the cookie, ...
Read MoreHow to show Page Loading div until the page has finished loading?
Rather than showing a blank white or black screen while loading the page, it is better to show a loading indicator, which improves the user experience of the application. Nowadays, there are many libraries available to show loading indicators. However, we can use HTML, CSS, and JavaScript to create a customized loading indicator div. In this tutorial, we will use HTML, CSS, and JavaScript to show page loading div until the page has finished loading. Use the onreadystatechange Event to Show the Loading Indicator In JavaScript, the onreadystatechange event triggers whenever the state of the web ...
Read MoreHow to create own Ajax functionality?
An Ajax (Asynchronous JavaScript and XML) request is an HTTP request made using JavaScript, typically with the XMLHttpRequest object, to exchange data with a server and update a specific part of a web page without requiring full page refresh. There are two ways to create own Ajax functionality: using JSONPlaceholder API or your own file. Using JSONPlaceholder API JSONPlaceholder is a free online REST API that you can use to test and practice your development skills. Syntax Users can follow the below syntax for creating an Ajax request using JavaScript's "XMLHttpRequest" object. let xhr ...
Read MoreHot Reload in ElectronJs
Hot reloading is a powerful feature in ElectronJS that lets developers quickly view their code changes in real time without having to restart the application. It makes the development process faster and more efficient by reducing the time and effort required to test changes. Steps to Implement Hot Reload in ElectronJS The hot reloading feature is implemented using a library called "electron-reload", and it can be easily integrated into an Electron JS application by following a few simple steps. Install the electron-reload module The first step in implementing hot reload in Electron JS is to install ...
Read MoreHow to view array of a structure in JavaScript?
The easiest way to debug JavaScript code is using console.log(), which many developers use. Sometimes, we need to know an array's structure and stored values for debugging purposes. In this tutorial, we will learn to view the structure of arrays containing different data types. Various JavaScript methods allow us to examine the structure of arrays. For example, we can see if an array contains objects, nested arrays, strings, numbers, or Boolean values. Using the JSON.stringify() Method The JSON.stringify() method converts JavaScript objects into JSON strings. Since arrays are objects in JavaScript, we can use this method to ...
Read MoreHow to wait resize end event and then perform an action using JavaScript?
When resizing a browser window, the 'resize' event fires continuously during the resize operation. This can cause performance issues if you execute heavy JavaScript code on every resize event. The solution is to wait until the resize operation ends before performing any action. The most common approach is using setTimeout() and clearTimeout() to create a debounced resize handler that only executes after the user stops resizing. Syntax let timeoutId; window.addEventListener('resize', () => { // Clear the previous timeout clearTimeout(timeoutId); // Set a ...
Read MoreHow to wrap setTimeout() method in a promise?
The setTimeout() method executes code or functions after a specified delay in milliseconds. When working with promises, you can wrap setTimeout() to create delayed asynchronous operations that resolve or reject after a specific time period. In JavaScript, a promise is an object that represents the eventual completion of an asynchronous operation. Here, we will learn to resolve or reject promises after some delay using the setTimeout() method. Basic Promise Without setTimeout() First, let's see a basic promise that resolves immediately without any delay: Using Promises without setTimeout() method ...
Read MoreHow to write a cell phone number in an international way using JavaScript?
When you have visitors from worldwide on your websites, it is a good idea to show things like a cell phone number according to international standards. So they can easily understand. We can use the International Public Telecommunication Numbering Format to represent the cell phone number in an international way. Also, it is represented by the 'E-164' format. We have given the syntax below to follow to write a cell phone number in an international way. [+] [country code] [local phone number] Users can see that the international phone number contains '+' initially ...
Read More