Front End Technology Articles

Page 360 of 652

Is their JavaScript scroll event for iPhone/iPad?

Abhinanda Shri
Abhinanda Shri
Updated on 15-Mar-2026 436 Views

Yes, iOS Safari captures scroll events on iPhone and iPad. However, iOS handles scrolling differently than desktop browsers, using momentum scrolling and gesture-based interactions. Basic Scroll Event Detection You can use the standard scroll event listener on iOS devices: Scroll this content on mobile... Content line 2 Content line 3 Content line 4 Content line 5 Scroll position: 0 const scrollable = document.getElementById('scrollable'); const output = ...

Read More

How to set height equal to the dynamic width (CSS fluid layout) in JavaScript?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 730 Views

To set height equal to the dynamic width in JavaScript, you can calculate the element's width and apply it as the height. This creates a perfect square that maintains its aspect ratio as the parent container resizes. Using jQuery jQuery provides a simple way to get and set element dimensions: .wrap { width: 400px; ...

Read More

What's the best way to detect a 'touch screen' device using JavaScript?

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

The best way to detect a touch screen device is to check whether touch events are supported in the browser's document model. This approach tests for the presence of touch event properties. Basic Touch Detection The most reliable method is to check for the ontouchstart property in the document element: function checkTouchDevice() { return 'ontouchstart' in document.documentElement; } // Test the function console.log("Touch device:", checkTouchDevice()); // Display result on page document.body.innerHTML = "Touch Device: " + checkTouchDevice() + ""; Enhanced Touch Detection Method For better compatibility ...

Read More

How to deal with Internet Explorer and addEventListener problem "Object doesn't support this property or method" in JavaScript?

George John
George John
Updated on 15-Mar-2026 2K+ Views

Internet Explorer versions 8 and below don't support the standard addEventListener() method, causing the "Object doesn't support this property or method" error. This article shows how to handle cross-browser event handling. The Problem Modern browsers use addEventListener() for event handling, but older Internet Explorer versions use attachEvent() instead. Using addEventListener() directly will fail in IE8 and below. Solution 1: Using IE=edge Meta Tag Force Internet Explorer to use its latest rendering engine by adding this meta tag to your HTML head: ...

Read More

What is JavaScript garbage collection?

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

JavaScript automatically manages memory allocation and deallocation through a process called garbage collection. When you declare variables or create objects, JavaScript allocates memory for them. The garbage collector then identifies and frees memory that is no longer needed by your application. How Garbage Collection Works JavaScript's garbage collector runs automatically in the background, scanning memory to find objects that are no longer reachable or referenced by your code. When these "orphaned" objects are found, their memory is freed up for reuse. Mark-and-Sweep Algorithm The most common garbage collection algorithm in modern JavaScript engines is the mark-and-sweep ...

Read More

How to convert a binary NodeJS Buffer to JavaScript ArrayBuffer?

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

Converting a binary NodeJS Buffer to JavaScript ArrayBuffer is a common requirement when working with binary data across different JavaScript environments. There are multiple approaches to achieve this conversion. Method 1: Using buf.buffer Property (Direct Access) The simplest approach is to access the buf.buffer property directly. However, this creates a view of the underlying ArrayBuffer, not a copy. const buffer = Buffer.from([1, 2, 3, 4, 5]); console.log("Original Buffer:", buffer); // Direct access to underlying ArrayBuffer const arrayBuffer = buffer.buffer; console.log("ArrayBuffer byteLength:", arrayBuffer.byteLength); // Create Uint8Array view to inspect data const uint8View = new Uint8Array(arrayBuffer); ...

Read More

How to create SVG graphics using JavaScript?

Govinda Sai
Govinda Sai
Updated on 15-Mar-2026 733 Views

SVG (Scalable Vector Graphics) can be dynamically created and manipulated using JavaScript. This allows you to generate interactive graphics, charts, and animations programmatically. Creating SVG Elements with JavaScript To create SVG elements in JavaScript, use document.createElementNS() with the SVG namespace. Here's how to create a basic SVG container and add shapes: SVG with JavaScript // SVG namespace ...

Read More

How to display JavaScript variables in an HTML page without document.write?

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

Use Element.innerHTML in JavaScript to display JavaScript variables in an HTML page without document.write(). This approach provides better control over content placement and doesn't overwrite the entire page. Basic Example: Displaying Variables Here's how to display JavaScript variables using innerHTML: Display Variables User Information Name: Age: City: // JavaScript variables ...

Read More

How to secretly copy to clipboard JavaScript function in Chrome and Firefox?

Lokesh Badavath
Lokesh Badavath
Updated on 15-Mar-2026 1K+ Views

In JavaScript, you can programmatically copy text to the clipboard without user interaction using different methods. This tutorial shows how to implement "secret" clipboard copying that works silently in the background. We'll explore both the legacy execCommand() method and the modern Clipboard API for copying text to clipboard programmatically. Using execCommand() Method (Legacy) The execCommand() method was traditionally used for clipboard operations. Here's a basic implementation: Copy text ...

Read More

How to work with JavaScript Drag and drop for touch devices?

Lokesh Badavath
Lokesh Badavath
Updated on 15-Mar-2026 6K+ Views

JavaScript drag and drop functionality provides an intuitive way to move elements within web pages. While the HTML5 Drag and Drop API works well on desktop, touch devices require additional handling to ensure proper functionality. Basic Drag and Drop Concepts To make an element draggable in HTML5, add the draggable="true" attribute to the element. By default, images and text selections are draggable, but other elements need this attribute. Drag me Drag and Drop Events The drag and drop process involves two sets of events: Events on draggable elements: dragstart - Fires ...

Read More
Showing 3591–3600 of 6,519 articles
« Prev 1 358 359 360 361 362 652 Next »
Advertisements