Programming Scripts Articles

Page 10 of 33

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

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 204 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

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

How to get the value of the usemap attribute of an image with JavaScript?

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

To get the value of the usemap attribute of an image, use the useMap property. This property returns the value of the usemap attribute, which specifies which image map to use with the image. Syntax let value = imageElement.useMap; Example ...

Read More

What is the usage of onhashchange event in JavaScript?

Anjana
Anjana
Updated on 15-Mar-2026 231 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

Flexbox and vertical scroll in a full-height app using newer Flexbox API with HTML

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

The flex property is a shorthand for the flex-grow, flex-shrink, and flex-basis properties. The flex property sets the flexible length on flexible items. When creating full-height applications with scrollable content areas, proper flexbox configuration is essential. Basic Flexbox Scroll Setup To create a scrollable flex item that takes up remaining space, use flex: 1 1 auto with overflow-y: auto: #container { display: flex; flex-direction: column; height: 100vh; } #container article { flex: 1 1 auto; ...

Read More

What is the usage of the onbeforeunload event in JavaScript?

Sravani S
Sravani S
Updated on 15-Mar-2026 223 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

HTML5 Canvas distorted

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

HTML5 Canvas distortion occurs when the canvas element's CSS dimensions don't match its internal drawing dimensions. This creates scaling issues that make drawings appear stretched or blurry. Understanding Canvas Dimensions Canvas has two sets of dimensions: Drawing dimensions: Set via width and height attributes Display dimensions: Set via CSS width and height properties When these don't match, the browser scales the drawing surface to fit the display size, causing distortion. Default Canvas Size The default canvas dimensions are: width = 300px height = 150px This gives a 2:1 aspect ...

Read More

What is the usage of onscroll event in JavaScript?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 250 Views

The onscroll event in JavaScript occurs when an element's scrollbar is being scrolled. This event is commonly used to create interactive features like scroll-triggered animations, infinite scrolling, or scroll position indicators. Syntax element.onscroll = function() { // Code to execute when scrolling }; // Or using addEventListener element.addEventListener('scroll', function() { // Code to execute when scrolling }); Basic Example Here's a simple example showing how to detect when a div element is scrolled: ...

Read More

SharedArrayBuffer.byteLength Property in JavaScript

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

The byteLength property of the SharedArrayBuffer returns an unsigned, 32-bit integer that specifies the size/length of a SharedArrayBuffer in bytes. Syntax sharedArrayBuffer.byteLength Parameters This property takes no parameters and is read-only. Return Value Returns the length of the SharedArrayBuffer in bytes as a 32-bit unsigned integer. Example JavaScript Example var sharedArrayBuffer = new SharedArrayBuffer(8); ...

Read More

What is the usage of onblur event in JavaScript?

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

The onblur event in JavaScript triggers when an HTML element loses focus. This commonly occurs when users click away from an input field, tab to another element, or programmatically change focus. Syntax // OR element.onblur = function() { /* code */ }; // OR element.addEventListener('blur', function() { /* code */ }); Example: Input Field Validation Enter your email and click outside the field: ...

Read More
Showing 91–100 of 328 articles
« Prev 1 8 9 10 11 12 33 Next »
Advertisements