HTML Articles

Page 86 of 151

Checking if a key exists in HTML5 Local Storage

Sreemaha
Sreemaha
Updated on 16-Mar-2026 2K+ Views

In HTML5 Local Storage, checking if a key exists is essential for avoiding errors and handling data appropriately. There are several methods to determine whether a specific key is present in localStorage before attempting to retrieve or manipulate its value. Syntax Following are the common syntaxes for checking if a key exists in localStorage − // Method 1: Using getItem() if (localStorage.getItem("keyName") !== null) { // key exists } // Method 2: Using 'in' operator if ("keyName" in localStorage) { // key exists } // Method ...

Read More

Is it possible to style HTML5 audio tag?

varma
varma
Updated on 16-Mar-2026 4K+ Views

HTML5 audio tags can be styled in multiple ways. By using the audio tag with the controls attribute, the default browser player is displayed. However, you can create completely custom audio controls by removing the controls attribute and building your own interface using HTML, CSS, and JavaScript. Syntax Following is the basic syntax for the HTML5 audio element − For custom controls without the default browser interface − Play Pause Styling Default Audio Controls The default browser controls have ...

Read More

How to programmatically empty browser cache with HTML?

usharani
usharani
Updated on 16-Mar-2026 3K+ Views

Browser caching improves website performance by storing files locally, but during development or when deploying updates, you may need to prevent caching to ensure users see the latest content. While HTML cannot directly empty the browser cache, it can control caching behavior through meta tags and cache-busting techniques. Understanding Browser Cache Control HTML provides meta tags that send HTTP headers to instruct browsers on how to handle caching. These directives tell the browser whether to cache the page, for how long, and when to revalidate the cached content. Syntax Following are the meta tags used to ...

Read More

How to fix getImageData() error 'The canvas has been tainted by cross-origin data' in HTML?

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

The getImageData() error "The canvas has been tainted by cross-origin data" occurs when you try to extract pixel data from a canvas that contains images loaded from external domains without proper CORS (Cross-Origin Resource Sharing) configuration. This security restriction prevents websites from accessing image data from other domains. When a canvas is "tainted" by cross-origin content, the browser blocks methods like getImageData(), toDataURL(), and toBlob() to prevent potential security vulnerabilities. Understanding Canvas Tainting Canvas tainting happens when you draw images from external domains onto a canvas without proper CORS headers. Once tainted, the canvas becomes read-only for ...

Read More

HTML 5 local Storage size limit for sub domains

Sreemaha
Sreemaha
Updated on 16-Mar-2026 716 Views

HTML5's localStorage provides a way to store data locally in the user's browser. However, it comes with size limitations to prevent abuse and ensure browser performance. The standard size limit is typically 5 to 10 MB per origin, with most browsers implementing a 5 MB limit. Understanding Origins and Subdomains In web storage context, an origin consists of the protocol, domain, and port. Each origin gets its own separate localStorage space. Importantly, subdomains are treated as separate origins, meaning subdomain1.example.com and subdomain2.example.com each have their own 5 MB storage limit. localStorage Origins and Size ...

Read More

Using HTML5 file uploads with AJAX and jQuery

Arjun Thakur
Arjun Thakur
Updated on 16-Mar-2026 728 Views

HTML5 provides robust support for file uploads using AJAX and jQuery, allowing you to upload files asynchronously without page refresh. This approach uses the File API to read file contents on the client side and send them to the server via AJAX requests. Syntax Following is the basic syntax for HTML5 file input − JavaScript FileReader API syntax − var reader = new FileReader(); reader.readAsText(file, 'UTF-8'); reader.onload = function(event) { /* handle result */ }; Client-Side Implementation The client-side code captures the file upload process and uses the ...

Read More

HTML5 check if audio is playing

mkotla
mkotla
Updated on 16-Mar-2026 5K+ Views

In HTML5, you can check if an audio element is currently playing by using the paused property. This property returns a boolean value indicating whether the audio is paused or playing. Syntax Following is the basic syntax to check if audio is playing − audioElement.paused The paused property returns false when the audio is playing and true when it is paused or stopped. Using a Function to Check Audio Status Following function checks if an audio element is currently playing − function isPlaying(audelem) { return !audelem.paused; ...

Read More

How do I add a simple onClick event handler to an HTML5 canvas element?

Ankith Reddy
Ankith Reddy
Updated on 16-Mar-2026 6K+ Views

The HTML5 canvas element creates a drawing surface where shapes and graphics are rendered as pixels, not DOM elements. Unlike regular HTML elements, canvas drawings have no built-in click detection. To handle click events on canvas shapes, you must capture clicks on the canvas element itself and calculate which drawn shape was clicked based on coordinates. Syntax Following is the syntax to add a click event listener to a canvas element − canvas.addEventListener('click', function(event) { // Handle click event }, false); How Canvas Click Detection Works Canvas click detection involves ...

Read More

How to save HTML Canvas as an Image with canvas.toDataURL()?

radhakrishna
radhakrishna
Updated on 16-Mar-2026 1K+ Views

The HTML5 Canvas provides the toDataURL() method to export canvas drawings as image data URLs. This method converts the canvas content into a base64-encoded data URL, typically in PNG format, which can be used to save, display, or download the canvas as an image file. Syntax Following is the syntax for the toDataURL() method − canvas.toDataURL(type, encoderOptions) Parameters type (optional) − A string indicating the image format. Default is "image/png". Other supported formats include "image/jpeg" and "image/webp". encoderOptions (optional) − A number between 0 and 1 indicating image quality ...

Read More

Client Checking file size using HTML5

Arjun Thakur
Arjun Thakur
Updated on 16-Mar-2026 495 Views

HTML5 provides a built-in File API that allows client-side file size checking without requiring Flash or server-side processing. This approach improves user experience by validating files before upload and provides immediate feedback to users. The File API is part of the HTML5 specification and is supported by all modern browsers. It allows JavaScript to access file properties including name, size, type, and last modified date through the files property of file input elements. Syntax Following is the basic syntax to access file size using the File API − var fileSize = document.getElementById('fileInput').files[0].size; The ...

Read More
Showing 851–860 of 1,509 articles
« Prev 1 84 85 86 87 88 151 Next »
Advertisements