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
Articles by Daniol Thomas
Page 2 of 13
How I can replace a JavaScript alert pop up with a fancy alert box?
Creating a custom fancy alert box gives you complete control over the design and user experience. Instead of the basic browser alert, you can create styled modal dialogs using HTML, CSS, and JavaScript. Using jQuery for Custom Alert Here's a complete example that replaces the standard JavaScript alert with a custom-styled modal: function functionAlert(msg, myYes) { var confirmBox = $("#confirm"); ...
Read MoreWhat records are present in JavaScript cookies?
Your server sends some data to the visitor's browser in the form of a cookie. The browser may accept the cookie. If it does, it is stored as a plain text record on the visitor's hard drive. Now, when the visitor arrives at another page on your site, the browser sends the same cookie to the server for retrieval. Once retrieved, your server knows/remembers what was stored earlier. Cookies are a plain text data record of 5 variable-length fields − Cookie Fields Structure Name = Value − Cookies are set and retrieved in ...
Read MoreIE supports the HTML5 File API
Internet Explorer's support for the HTML5 File API varies by version. IE9 does not support the File API, but IE10 and later versions provide full support for file operations. File API Browser Support The File API allows web applications to read file contents and metadata. Here's the IE support timeline: IE9: No File API support IE10+: Full File API support including FileReader, File, and Blob objects Modern browsers: Complete support across Chrome, Firefox, Safari, and Edge Example: File Reading with File API This example ...
Read MoreUpdate HTML5 canvas rectangle on hover
To update HTML5 canvas rectangle on hover, you need to handle mouse events and redraw the canvas. Here's how to create a rectangle that changes color when you hover over it. Basic Setup First, create a canvas element and get its context: var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); // Draw initial rectangle function drawRectangle(fillColor) { context.clearRect(0, 0, canvas.width, canvas.height); context.rect(20, 20, 150, 100); context.strokeStyle = "black"; context.stroke(); ...
Read MoreHow to handle mousedown and mouseup with HTML5 Canvas
To handle the mousedown and mouseup events with HTML5 Canvas, you can attach event listeners directly to the canvas element. These events are useful for creating interactive graphics, drag-and-drop functionality, or drawing applications. Basic Syntax canvas.addEventListener('mousedown', function(event) { // Handle mouse press }); canvas.addEventListener('mouseup', function(event) { // Handle mouse release }); Example: Simple Click Detection const canvas = document.getElementById('myCanvas'); const ctx = canvas.getContext('2d'); let mouseDown = false; // Draw initial state ctx.fillStyle = '#f0f0f0'; ctx.fillRect(0, 0, 400, 300); ctx.fillStyle = ...
Read MoreDoes use of anonymous functions affect performance?
Anonymous functions in JavaScript have minimal performance impact in modern engines. While they create new function objects each time, the difference is negligible unless used in tight loops or performance-critical code. What are Anonymous Functions? Anonymous functions are functions without a name identifier. They are typically assigned to variables or passed as arguments to other functions. var func = function() { console.log('This is anonymous'); } func(); This is anonymous Performance Comparison Here's a comparison between named and anonymous functions: // Named function ...
Read MoreHow to set current time to some other time in JavaScript?
You cannot directly modify the system time with JavaScript since it uses the system's clock through the Date object. However, you can simulate different times by adjusting timezones or creating custom date objects with specific values. Method 1: Using Timezone Conversion You can display time for different timezones by calculating the offset from UTC: var date, utc, offset, singaporeTime; date = new Date(); ...
Read MoreWhat are the differences between group and layer in KineticJs with HTML?
In KineticJS, groups and layers serve different organizational purposes when building HTML5 canvas applications. Understanding their differences is crucial for proper scene management. What are Groups? Groups are containers that hold multiple shape objects within a layer. They allow you to treat multiple shapes as a single unit for transformations and event handling. var stage = new Konva.Stage({ ...
Read MoreWhat are secured cookies in JavaScript?
Secured cookies in JavaScript are cookies with special security attributes that protect against common web vulnerabilities. They use two main flags: Secure and HttpOnly to enhance security. What Makes a Cookie Secured? A secured cookie has two key attributes: Secure flag - Cookie is only sent over HTTPS connections HttpOnly flag - Cookie cannot be accessed via JavaScript The Secure Attribute The Secure attribute ensures cookies are only transmitted over encrypted HTTPS connections, preventing interception over unsecured HTTP. // Setting a secure cookie (server-side example) document.cookie = "sessionId=abc123; Secure; Path=/"; ...
Read MoreMediaStream in HTML5
The MediaStream represents synchronized streams of media content in HTML5. It provides access to audio and video tracks from sources like microphones and webcams. When there are no audio tracks, it returns an empty array, and for video streams, if a webcam is connected, stream.getVideoTracks() returns an array containing MediaStreamTrack objects representing the webcam stream. Getting User Media Access The navigator.mediaDevices.getUserMedia() method is the modern way to access media streams. It returns a Promise that resolves with a MediaStream object: Start Audio async function startAudio() { try { ...
Read More