Javascript Articles

Page 360 of 534

How to draw a 3D sphere in HTML5?

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

To create a 3D sphere in HTML5, you need to use the canvas element along with mathematical calculations to plot points in 3D space and project them onto a 2D canvas. This involves creating vertices using spherical coordinates and rendering them as a wireframe or solid sphere. Basic Sphere Class Structure First, let's create a Point3D class and a sphere display function: 3D Sphere // Point3D class to represent ...

Read More

HTML5 video not working with jquery bxSlider plugin on iPad

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 260 Views

When using HTML5 video with the bxSlider jQuery plugin on iPad, video playback often fails due to iOS-specific requirements and plugin compatibility issues. This guide shows how to properly configure bxSlider to work with HTML5 videos on iPad. Setup Requirements First, download the bxSlider plugin from the official website. Extract the downloaded zip file and locate the images folder. Copy this images folder into your project's js directory. Required Files Structure Include the following files in your project with proper linking: HTML Structure for Video Slider Structure ...

Read More

Remove Seconds/ Milliseconds from Date and convert to ISO String?

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

In JavaScript, you can remove seconds and milliseconds from a Date object and convert it to an ISO string format. This is useful when you need precise time formatting without the seconds component. Getting the Current Date First, let's create a Date object with the current date and time: var currentDate = new Date(); console.log("The current date is: " + currentDate); The current date is: Sat Aug 01 2020 18:20:09 GMT+0530 (India Standard Time) Removing Seconds and Milliseconds Use the setSeconds() method to set both seconds and milliseconds to 0: ...

Read More

Configuring any CDN to deliver only one file no matter what URL has been requested

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 205 Views

Content Delivery Networks (CDNs) are typically designed to serve static files based on specific URL paths. However, there are scenarios where you need a CDN to deliver the same file regardless of the requested URL - commonly used for Single Page Applications (SPAs) that rely on client-side routing. Why Serve One File for All URLs? Single Page Applications like React, Vue, or Angular apps use client-side routing. When users navigate to different URLs, the same index.html file should be served, and JavaScript handles the routing internally. Method 1: Using CloudFlare Page Rules CloudFlare allows you to ...

Read More

Retrieving object's entries in order with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 297 Views

In JavaScript, object properties don't maintain insertion order for numeric keys, but we can retrieve entries in sorted order using Object.keys() and sort() methods. The Problem Consider an object with numeric keys that aren't in sequential order: const subjectDetails = { 102: "Java", 105: "JavaScript", 104: "MongoDB", 101: "MySQL" }; console.log("Original object:"); console.log(subjectDetails); Original object: { '101': 'MySQL', '102': 'Java', '104': 'MongoDB', '105': 'JavaScript' } ...

Read More

How to draw sine waves with HTML5 SVG?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 1K+ Views

To draw sine waves with HTML5 SVG, you can use the element with cubic Bezier curves to closely approximate the smooth curves of a sine wave. This approach provides precise control over wave shape and amplitude. Basic Sine Wave Example Here's how to create a simple sine wave using SVG path with cubic Bezier approximation: SVG Sine Waves HTML5 SVG Sine Wave ...

Read More

Can someone explain to me what the plus sign is before the variables in JavaScript?

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

The plus (+) sign before a variable in JavaScript is the unary plus operator. It converts the value to a number, making it useful for type conversion from strings, booleans, or other data types to numeric values. Syntax +value How It Works The unary plus operator attempts to convert its operand to a number. It works similarly to Number() constructor but with shorter syntax. Example: String to Number Conversion var firstValue = "1000"; console.log("The data type of firstValue = " + typeof firstValue); var secondValue = 1000; console.log("The data type ...

Read More

Align HTML5 SVG to the center of the screen

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 3K+ Views

SVG stands for Scalable Vector Graphics and it is a language for describing 2D-graphics and graphical applications in XML. HTML5 provides native SVG support, and centering SVG elements on a webpage requires specific CSS techniques. Method 1: Using Auto Margins and Display Block The simplest way to center an SVG horizontally is using auto margins with display block: #svgelem { margin-left: auto; ...

Read More

Split a URL in JavaScript after every forward slash?

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

To split a URL in JavaScript, use the split() method with a forward slash (/) as the delimiter. This breaks the URL into an array of segments. Syntax url.split("/") Basic Example var newURL = "http://www.example.com/index.html/homePage/aboutus/"; console.log("Original URL:", newURL); var splitURL = newURL.split("/"); console.log("Split URL:", splitURL); Original URL: http://www.example.com/index.html/homePage/aboutus/ Split URL: [ 'http:', '', 'www.example.com', 'index.html', 'homePage', 'aboutus', '' ] Understanding the Output The result contains empty strings because: Index 0: 'http:' ...

Read More

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

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 363 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
Showing 3591–3600 of 5,340 articles
« Prev 1 358 359 360 361 362 534 Next »
Advertisements