Smita Kapse

Smita Kapse

388 Articles Published

Articles by Smita Kapse

Page 2 of 39

How to rotate an image with the canvas HTML5 element from the bottom center angle?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 355 Views

Rotating an image from the bottom center in HTML5 Canvas requires translating the canvas origin to the rotation point, applying the rotation, then drawing the image at an offset position. Understanding Canvas Rotation Canvas rotation always occurs around the origin (0, 0). To rotate from a specific point like bottom center, we must: Translate the canvas to the rotation point Apply the rotation Draw the image at an adjusted position Complete Example const canvas = document.getElementById('myCanvas'); const context = canvas.getContext('2d'); // Create an image const img = new ...

Read More

How to make flexible items display in columns with JavaScript?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 249 Views

The flexFlow property in CSS controls how flexible items are arranged within a flex container. To display items in columns using JavaScript, you can modify this property dynamically. Understanding flexFlow The flexFlow property is a shorthand that combines flex-direction and flex-wrap. For column layout, use column for direction and nowrap or wrap for wrapping behavior. Example Here's how to change flexible items from row to column layout using JavaScript: #box { ...

Read More

How to check web browser support in HTML5

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 303 Views

Checking web browser support for HTML5 features is essential for creating compatible web applications. This guide shows you how to detect HTML5 features using both modern JavaScript methods and the Modernizr library. Using Modernizr Library Modernizr is a popular JavaScript library that detects HTML5 and CSS3 features. Here's how to check for web worker support: Web Worker Support Check function checkWebWorkerSupport(){ ...

Read More

cache.manifest works for the first time then fails in HTML

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 115 Views

HTML5 Application Cache (cache.manifest) can fail after the first load due to caching issues. Here are solutions to ensure proper cache updates. Add NETWORK Section Add the NETWORK section at the bottom of your manifest file to allow network access for unlisted resources: CACHE MANIFEST CACHE: /css/style.css /js/myscript.js /images/logo.png NETWORK: * Version Your Manifest File Include a version parameter in the manifest attribute to force cache updates when content changes: My App Cached Application ...

Read More

What is the usage of oninvalid event in JavaScript?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 327 Views

The oninvalid event is triggered when a form field fails HTML5 validation constraints. It fires before form submission when an field with validation attributes (like required, pattern, etc.) contains invalid data. Syntax element.oninvalid = function() { // Handle invalid input }; // Or in HTML Basic Example Here's how to use oninvalid to show custom validation messages: Enter Name: ...

Read More

How to prevent text select outside HTML5 canvas on double-click?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 374 Views

When users double-click on or near an HTML5 canvas element, browsers may inadvertently select surrounding text. This creates a poor user experience, especially in interactive applications. Here's how to prevent this behavior. The Problem Double-clicking near a canvas element can trigger text selection in surrounding elements, highlighting unwanted text and disrupting the user interface. Solution: Disable Text Selection Set the onselectstart event handler to return false, which prevents the browser from starting text selection on the canvas element. var canvas = document.getElementById('myCanvas'); // Prevent text selection on double-click canvas.onselectstart = ...

Read More

What are JavaScript Identifiers?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 5K+ Views

JavaScript identifiers are names given to variables, functions, classes, objects, and other entities in your code. They work similarly to identifiers in other programming languages like C, C++, and Java, but have specific rules you must follow. What are Identifiers? An identifier is simply a name that you create to reference a variable, function, or other code element. Here are some examples of valid identifiers: // Valid variable identifiers let userName = "John"; let age = 25; let _privateVar = "hidden"; let $element = "jQuery style"; let camelCaseVariable = "standard naming"; console.log(userName); console.log(age); console.log(_privateVar); ...

Read More

How to convert a Unix timestamp to time in JavaScript?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 274 Views

To convert a Unix timestamp to time in JavaScript, you need to multiply the timestamp by 1000 (since Unix timestamps are in seconds, but JavaScript Date expects milliseconds) and then use Date methods to extract time components. What is a Unix Timestamp? A Unix timestamp represents the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC. JavaScript's Date constructor expects milliseconds, so we multiply by 1000. Example JavaScript Dates ...

Read More

Detect folders in Safari with HTML5

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 186 Views

Safari has limited support for folder detection compared to other browsers. When users drag and drop folders, Safari treats them differently than individual files, which can cause errors during file reading operations. The Problem with Folders in Safari When a folder is dropped onto a web page, Safari includes it in the files collection but cannot read its contents using FileReader. This causes the onerror event to trigger, which we can use to detect folder drops. Folder Detection Method The following code attempts to read each dropped item as a file. If it's a folder, the ...

Read More

How can I list all cookies on the current page with JavaScript?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 1K+ Views

In JavaScript, you can list all cookies on the current page using the document.cookie property. This property returns a string containing all cookies as semicolon-separated key-value pairs. Basic Cookie Retrieval The simplest way to get all cookies is to access document.cookie directly: // Set some sample cookies first document.cookie = "username=john; path=/"; document.cookie = "theme=dark; path=/"; ...

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