Javascript Articles

Page 351 of 534

Why can't my HTML file find the JavaScript function from a sourced module?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

When an HTML file cannot find JavaScript functions from a sourced module, it's usually because the function isn't properly exported from the module or the import statement is incorrect. ES6 modules require explicit export/import statements to share functions between files. The Export Problem Functions in JavaScript modules are not globally accessible unless explicitly exported. Without the export keyword, functions remain private to the module. demo.js console.log("function will import"); export function test(){ console.log("Imported!!!"); } Example: Complete Module Import index.html ...

Read More

Generating sound on the fly with JavaScript/ HTML5

Prabhas
Prabhas
Updated on 15-Mar-2026 457 Views

The Web Audio API is used to control audio, which allows you to choose audio sources. You can also add effects, create audio visualizations, panning, and generate sounds programmatically in web browsers. Basic Sound Generation To generate sound with the Web Audio API, you need three main components: an AudioContext, an oscillator (sound source), and a destination (speakers). Here's how to create a simple tone: Generate Sound Play 500Hz Tone ...

Read More

Does HTML5 allow you to interact with local client files from within a browser?

varun
varun
Updated on 15-Mar-2026 400 Views

HTML5 allows web applications to interact with local client files through powerful APIs. These interfaces enable browsers to access the user's file system, read binary data, and handle file operations that were previously impossible with standard web technologies. HTML5 File APIs HTML5 provides three main APIs for file interaction: File API - Read file contents and metadata File System API - Access file system structure (deprecated in modern browsers) File Writer API - Write data to files (limited browser support) Reading Local Files The ...

Read More

How to remove an object using filter() in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 653 Views

The filter() method creates a new array with elements that pass a test condition. It's commonly used to remove objects from arrays based on specific criteria. Initial Array Let's start with an array of objects where some have a details property and others don't: let objectValue = [ { "id": "101", "details": { "Name": "John", "subjectName": "JavaScript" }}, { "id": "102", "details": { "Name": "David", "subjectName": "MongoDB" }}, { "id": "103" } ]; console.log("Original array:"); console.log(objectValue); Original array: [ ...

Read More

How to replace default meta tag from "layout" with customizing meta tags in "view" with HTML?

usharani
usharani
Updated on 15-Mar-2026 294 Views

Meta tags provide essential information about HTML documents, including descriptions, keywords, and author details. When building web applications, you often need default meta tags in your layout that can be customized for specific pages or views. The most effective approach is to define default meta tags in your application configuration and override them in individual views when needed. This ensures consistent metadata while allowing page-specific customization. Step 1: Configure Default Meta Tags First, define your default meta tag values in the application configuration file: Step 2: Register Meta Tags in Layout ...

Read More

How to get only the first BOT ID from thes JavaScript array?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 141 Views

When working with an array of objects in JavaScript, you often need to access specific properties from the first element. Let's explore how to get the first BOT ID from an array of user records. Sample Data Structure Consider an array of objects where each object contains a BOTID and Name: let objectArray = [ { BOTID: "56", Name: "John" }, { BOTID: "57", Name: "David" }, { BOTID: "58", Name: "Sam"}, { BOTID: "59", Name: "Mike" }, ...

Read More

How to save DIV as Image with HTM5 canvas to image with the extension?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 6K+ Views

Converting HTML DIV content to images is useful for generating reports, creating downloadable content, or saving visual elements. The html2canvas library makes this process straightforward by converting DOM elements into canvas, which can then be saved as images. Installation First, include the html2canvas library in your HTML: Basic HTML Structure Create a DIV with content you want to convert: Welcome to TutorialsPoint! ...

Read More

HTML5/CSS align list-items depending on other columns mutual height

varma
varma
Updated on 15-Mar-2026 251 Views

When working with HTML5 and CSS, aligning list items across columns of different heights is a common layout challenge. Using CSS Flexbox provides an elegant solution for creating flexible, responsive columns with proper alignment. Basic Flex Layout Structure The wrapper container uses display: flex to create a flexible row layout: .wrap { display: flex; } .wrap .col { flex: 1 0 33%; } The flex: 1 0 33% property means each column will grow equally, never shrink below its content size, and start with a ...

Read More

Transform nested array into normal array with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 329 Views

In JavaScript, nested arrays can be flattened into a single-level array using several methods. The most common approach is the flat() method, which removes one level of nesting by default. What is Array Flattening? Array flattening transforms a nested array structure into a single-dimensional array. For example, converting [[1, 2], [3, 4]] into [1, 2, 3, 4]. Using flat() Method The flat() method creates a new array with sub-array elements flattened into it. Here's how to flatten a nested array containing objects: const arrayObject = [ [ ...

Read More

How to change date time format in HTML5?

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 3K+ Views

HTML5 provides several input types for date and time, but formatting them requires JavaScript. The default browser format can be customized using JavaScript date methods or libraries. HTML5 Date Input Types HTML5 offers various date and time input types: Basic Date Formatting with JavaScript You can format dates using JavaScript's built-in methods: const dateInput = document.getElementById('dateInput'); const output = document.getElementById('output'); dateInput.addEventListener('change', function() { const date = new Date(this.value); ...

Read More
Showing 3501–3510 of 5,340 articles
« Prev 1 349 350 351 352 353 534 Next »
Advertisements