Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Javascript Articles
Page 360 of 534
How to draw a 3D sphere in HTML5?
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 MoreHTML5 video not working with jquery bxSlider plugin on iPad
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 MoreRemove Seconds/ Milliseconds from Date and convert to ISO String?
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 MoreConfiguring any CDN to deliver only one file no matter what URL has been requested
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 MoreRetrieving object's entries in order with JavaScript?
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 MoreHow to draw sine waves with HTML5 SVG?
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 MoreCan someone explain to me what the plus sign is before the variables in JavaScript?
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 MoreAlign HTML5 SVG to the center of the screen
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 MoreSplit a URL in JavaScript after every forward slash?
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 MoreHow to rotate an image with the canvas HTML5 element from the bottom center angle?
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