HTML Articles

Page 126 of 151

How to search the alternate text of an image-map area in JavaScript?

Sravani S
Sravani S
Updated on 15-Mar-2026 203 Views

To search the alternate (alt) text of an image-map area in JavaScript, use the alt property. This property allows you to access or modify the alternative text that describes the image map area for accessibility purposes. Syntax // Get alt text let altText = areaElement.alt; // Set alt text areaElement.alt = "new alt text"; Example: Accessing Alt Text of Image Map Area ...

Read More

What is the role of scrollX property in JavaScript?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 646 Views

The scrollX property in JavaScript returns the number of pixels the document has been scrolled horizontally from the left edge of the viewport. It's equivalent to the older pageXOffset property and is read-only. Syntax let horizontalScroll = window.scrollX; Return Value Returns a number representing the horizontal scroll position in pixels. The value is 0 when the document is not scrolled horizontally. Example: Basic scrollX Usage .content { ...

Read More

How to search and display the pathname part of the href attribute of an area with JavaScript?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 196 Views

To get the pathname part of the href attribute of an area in JavaScript, use the pathname property. This property extracts just the path portion from a URL, excluding the protocol, domain, and query parameters. Syntax areaElement.pathname Example You can try to run the following code to display the pathname part of an area element's href attribute. ...

Read More

What is the usage of an abort event in JavaScript?

Sai Nath
Sai Nath
Updated on 15-Mar-2026 475 Views

The abort event fires when the loading of a media resource is aborted, typically for images, videos, or audio elements. This event occurs when the user navigates away from the page or explicitly stops the loading process before it completes. When the abort Event Occurs The abort event is triggered in several scenarios: User navigates away from the page while an image is loading Loading is interrupted by clicking a link or refreshing the page Network connection is lost during resource loading The loading process is programmatically canceled Example: Basic abort Event Handler ...

Read More

What will happen when 0 is converted to Number in JavaScript?

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 151 Views

Use the Number() method in JavaScript to convert values to Number type. When converting 0 to Number, it remains 0 since it's already a valid number. Basic Conversion Converting 0 to Number returns 0, as zero is already a number: Convert 0 to Number var myVal = 0; document.write("Number: " + Number(myVal)); ...

Read More

How to stop the execution of a function with JavaScript?

Jennifer Nicholas
Jennifer Nicholas
Updated on 15-Mar-2026 9K+ Views

To stop the execution of a function in JavaScript, you have several methods depending on the type of execution. The most common approaches involve clearing timers or using control flow statements. Using clearTimeout() for setTimeout() The clearTimeout() method stops functions scheduled with setTimeout(): Stop Function Execution Click the buttons below to handle animation Start Stop var ...

Read More

What will happen when 1 is converted to Boolean in JavaScript?

Paul Richard
Paul Richard
Updated on 15-Mar-2026 183 Views

In JavaScript, when the number 1 is converted to Boolean, it becomes true. This is because 1 is considered a "truthy" value in JavaScript's type conversion system. Understanding Truthy and Falsy Values JavaScript has specific rules for Boolean conversion. The number 1 (and all non-zero numbers) are truthy values, meaning they convert to true. Example: Converting 1 to Boolean Convert 1 to Boolean var myVal = 1; document.write("Boolean: " ...

Read More

What is the usage of onhashchange event in JavaScript?

Anjana
Anjana
Updated on 15-Mar-2026 222 Views

The onhashchange event occurs when the anchor part (hash) of the URL changes. This event is useful for creating single-page applications where different URL fragments represent different views or states. Syntax window.onhashchange = function() { // Code to execute when hash changes }; // Or using addEventListener window.addEventListener('hashchange', function() { // Code to execute when hash changes }); Example: Basic Hash Change Detection Change to #about Change to #contact ...

Read More

How to set all the border bottom properties in one declaration in JavaScript DOM?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 198 Views

To set all border bottom properties in one declaration using JavaScript DOM, use the borderBottom property. This property allows you to simultaneously set the border-bottom-width, border-bottom-style, and border-bottom-color in a single statement. Syntax element.style.borderBottom = "width style color"; Parameters The borderBottom property accepts a string value containing three space-separated components: width: Border thickness (e.g., "thin", "medium", "thick", "2px", "5px") style: Border style (e.g., "solid", "dashed", "dotted", "double") color: Border color (e.g., "red", "#ff0000", "rgb(255, 0, 0)") Example Here's how to set border bottom properties using JavaScript: ...

Read More

What is the usage of the onbeforeunload event in JavaScript?

Sravani S
Sravani S
Updated on 15-Mar-2026 215 Views

The onbeforeunload event triggers when a user attempts to leave the page, such as closing the tab, refreshing, or navigating to another URL. It's commonly used to warn users about unsaved changes. Syntax window.onbeforeunload = function(event) { // Return a string to show confirmation dialog return "Your message here"; }; // Or using addEventListener window.addEventListener('beforeunload', function(event) { event.preventDefault(); event.returnValue = ''; }); Example: Basic Implementation onbeforeunload Example ...

Read More
Showing 1251–1260 of 1,509 articles
« Prev 1 124 125 126 127 128 151 Next »
Advertisements