Nikhilesh Aleti

Nikhilesh Aleti

69 Articles Published

Articles by Nikhilesh Aleti

Page 2 of 7

Execute a script when a user navigates to a page in HTML?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 16-Mar-2026 297 Views

The onpageshow event in HTML allows you to execute a script whenever a user navigates to a page. This event fires every time a page loads, including when users navigate back using the browser's back button or reload the page. HTML onpageshow Event The onpageshow event occurs when a user navigates to a webpage. Unlike the onload event, onpageshow fires even when the page is loaded from the browser cache, making it ideal for initialization scripts that need to run every time the page is displayed. Syntax Following is the syntax for the onpageshow event in ...

Read More

How to specify the HTML content of the page to show in the <iframe&gt in HTML?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 16-Mar-2026 4K+ Views

In this article, we need to display the HTML content of the page in an iframe; a browser window divided as a separate page. We can achieve this task using the tag and its srcdoc attribute. HTML Tag The tag in HTML specifies an inline frame. This inline frame is used to embed another document within the current HTML document. This tag is supported by all modern browsers including Google Chrome, Microsoft Edge, Firefox, Safari, and Opera. The srcdoc attribute of the tag is used to specify the HTML content of the page ...

Read More

How do we embed custom data attributes on all HTML elements?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 16-Mar-2026 655 Views

Custom data attributes in HTML allow you to embed custom data private to your webpage or application. The data-* attribute adds custom values to any HTML element without interfering with the standard HTML structure or validation. Data attributes are commonly used to store extra information that can be accessed later via JavaScript for enhanced user interactions, configurations, or metadata storage. Syntax Following is the syntax for using custom data attributes − Content The data-* attribute consists of two parts − Attribute name − Must start with "data-" followed by at ...

Read More

DHTML JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 6K+ Views

DHTML stands for Dynamic Hypertext Markup Language. DHTML combines HTML, CSS, and JavaScript to create interactive and dynamic web pages. It allows for customization and changes to the content based on user inputs. Earlier, HTML was used to create static pages that only defined the structure of the content. CSS helped in enhancing the page's appearance. However, these technologies were limited in their ability to create interactive experiences. DHTML introduced JavaScript and the Document Object Model (DOM) to make web pages dynamic. With DHTML, the web page can be manipulated and updated in response to user actions, eliminating the ...

Read More

File Type Validation while Uploading it using JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 7K+ Views

File type validation is essential for web applications that handle file uploads. It ensures users only upload acceptable file formats, preventing security issues and maintaining data consistency. JavaScript provides built-in properties to check file types before submission. This validation process helps platforms like job portals, social media sites, and document management systems control what file types users can upload, such as restricting uploads to PDFs for resumes or images for profile pictures. How File Type Validation Works When a user selects a file, the browser exposes file information through the File API. The key property is file.type, ...

Read More

Create a Hoverable Side Navigation with HTML, CSS and JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 468 Views

A navigation bar is part of a webpage that contains links to appropriate sections/pages in a website, helping users browse fast and effortlessly. The navigation bar can be implemented in many ways, but the traditional approaches are horizontal and vertical bars. In this article, we'll design a vertical side navigation bar with hoverable buttons using HTML, CSS, and JavaScript. The navigation slides out when hovered and displays content when clicked. Project Structure Overview Our hoverable side navigation consists of three main components: HTML - Structure for navigation links and content sections ...

Read More

Removing all the empty indices from array in JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 2K+ Views

When working with JavaScript arrays, you may encounter arrays with empty indices (holes). These empty slots can cause issues in data processing. This article shows different methods to remove empty indices and create clean arrays. Understanding Empty Indices Empty indices in arrays are undefined slots that exist but have no value assigned: Empty Indices Example const array = [22, 45, , 56, 71, , 10]; console.log("Original array:", array); ...

Read More

Function to compute factorial of a number in JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 13K+ Views

In this article, we will explore different methods to calculate the factorial of a number in JavaScript. What is Factorial? The factorial of a non-negative integer n is the product of all positive integers less than or equal to n. For example, the factorial of 4 is 4 × 3 × 2 × 1 = 24, represented as 4!. The value of 0! is defined as 1 by convention. Mathematical Formula The factorial of n is represented as n! and calculated using: n! = n × (n-1) × (n-2) × ... × 3 ...

Read More

Return an array of all the indices of minimum elements in the array in JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 1K+ Views

In JavaScript arrays, you might need to find all indices where the minimum value appears. This is useful when the smallest element occurs multiple times and you want to locate all positions. Problem Statement Given an array with duplicate minimum values, we need to return an array containing all indices of these minimum elements. Input: [10, 22, 30, 44, 10, 22, 30, 10, 10] Output: [0, 4, 7, 8] Here, 10 is the minimum value appearing at indices 0, 4, 7, and 8. Using Math.min() with Spread Operator Math.min() returns the smallest ...

Read More

Converting string to an array in JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 48K+ Views

In JavaScript, converting strings to arrays is a common task when you need to split text into characters or words for processing. JavaScript provides several built-in methods to accomplish this conversion efficiently. This article explores four different methods to convert strings to arrays, each suitable for different use cases and requirements. Using the split() Method The split() method is the most versatile approach for string-to-array conversion. It splits a string into an array of substrings based on a specified separator and returns a new array without modifying the original string. The split() method accepts two optional ...

Read More
Showing 11–20 of 69 articles
« Prev 1 2 3 4 5 7 Next »
Advertisements