Articles on Trending Technologies

Technical articles with clear explanations and examples

How to block a website in your web browsers (Chrome and Internet Explorer)

Johar Ali
Johar Ali
Updated on 15-Mar-2026 435 Views

To block a website on web browsers like Google Chrome, Firefox, and Internet Explorer in a Windows system, you can modify the system's hosts file. This method works by redirecting website requests to your local machine. How It Works The hosts file acts as a local DNS lookup table. When you add an entry like 127.0.0.1 website.com, your system redirects that website to your local machine (127.0.0.1), effectively blocking access. Step-by-Step Instructions Step 1: Open Notepad as an administrator by right-clicking on Notepad and selecting Run as Administrator. Step 2: In Notepad, click File → ...

Read More

How to show the number of links in a document with JavaScript?

Abhishek Kumar
Abhishek Kumar
Updated on 15-Mar-2026 888 Views

We use the links property of the document object to show the number of links in a document with JavaScript. The document object, part of the DOM, corresponds to the current web page that the browser has loaded. It contains all the information about the condition of the browser as well as the web page. The links is a property of the document object that returns a list of all the hyperlinks present in the HTML document. A hyperlink may look something like this: "https://www.tutorialspoint.com/php" The links property of the document object lists all HTML ...

Read More

Calculate text width with JavaScript

Sravani Alamanda
Sravani Alamanda
Updated on 15-Mar-2026 10K+ Views

To calculate text width, we can use the measureText() method in JavaScript. In canvas, the measureText() method is used to measure width of the text content. This means we can pass text to this canvas method and then call that method to measure the text. It will return an object that contains information about the measured text. Sometimes, width may be a float value; hence the Math.ceil() method is used to round the value and returns an integer. Syntax Following is the syntax of the method used to calculate the text width: const text = ...

Read More

Frame by frame animation in HTML5 with canvas

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 854 Views

Frame by frame animation in HTML5 canvas creates smooth animations by displaying a sequence of images in rapid succession, similar to traditional flipbook animation. Basic Frame Animation Structure The core concept involves cycling through numbered image files and drawing them onto the canvas at regular intervals using setInterval(). Complete Example Frame Animation var canvas = document.getElementById('animationCanvas'); ...

Read More

Usage of CSS border-collapse property

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 96 Views

The border-collapse CSS property controls how adjacent table cell borders are displayed. It determines whether borders should merge together or remain separate. Syntax border-collapse: collapse | separate | initial | inherit; Values Value Description collapse Adjacent borders are merged into a single border separate Each cell maintains its own borders (default) initial Sets to default value (separate) inherit Inherits from parent element Example Here's a comparison showing both collapse and separate values: ...

Read More

Difference between application/x-javascript and text/javascript content types?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 1K+ Views

When serving JavaScript files, choosing the correct MIME type is crucial for proper browser handling. Let's explore the differences between these content types and understand which one to use. text/javascript (Obsolete) The text/javascript content type was used in the early days of HTML but is now obsolete according to RFC 4329. While browsers still support it for backward compatibility, it should not be used in modern applications. // Server header (obsolete) Content-Type: text/javascript application/x-javascript (Experimental) application/x-javascript was an experimental content type, indicated by the "x-" prefix. The "x-" denotes non-standard or experimental MIME ...

Read More

How to trigger a button click on keyboard "enter" with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

To trigger a button click when the user presses the "Enter" key, you can use JavaScript's event listeners to detect the keypress and programmatically trigger the button's click event. Basic Example Here's a complete example that triggers a button click when Enter is pressed inside an input field: Trigger Button Click on Enter Trigger Button Click on Enter Example Click ...

Read More

How to pass arguments to anonymous functions in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

Anonymous functions in JavaScript are functions without a name that can accept parameters just like regular functions. You can pass arguments to them through function calls, event handlers, or higher-order functions. What are Anonymous Functions? Anonymous functions are functions declared without a name. They're often assigned to variables or used as callback functions. Anonymous Functions Anonymous Function Examples Run Examples ...

Read More

Adding two arrays of objects with existing and repeated members of two JavaScript arrays replacing the repeated ones

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 200 Views

When working with arrays of objects in JavaScript, you often need to merge them while avoiding duplicates. This tutorial shows how to combine two arrays of objects and remove duplicates based on a specific property. The Problem Consider two arrays of objects where some objects have the same name property. We want to merge them into one array, keeping only unique entries based on the name field. const first = [{ name: 'Rahul', age: 23 }, { name: 'Ramesh', age: ...

Read More

Check for Power of two in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

We need to write a function, isPowerOfTwo(), that takes a positive number and returns a boolean based on whether the number is a power of 2. For example: isPowerOfTwo(3) // false (3 is not a power of 2) isPowerOfTwo(32) // true (32 = 2^5) isPowerOfTwo(2048) // true (2048 = 2^11) isPowerOfTwo(256) // true (256 = 2^8) isPowerOfTwo(22) // false (22 is not a power of 2) Method 1: Using Recursive Division This approach recursively divides the number by 2 until it reaches 1 (power of 2) ...

Read More
Showing 16981–16990 of 61,297 articles
Advertisements