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 Giri Raju
Page 2 of 7
How to format hexadecimal Number in JavaScript?
JavaScript provides several methods to format hexadecimal numbers. The most common approach is using toString(16) to convert numbers to hexadecimal format, then applying padding and formatting as needed. Basic Hexadecimal Conversion The toString(16) method converts a number to its hexadecimal representation: let num = 255; let hex = num.toString(16); document.write("Number: " + num + ""); document.write("Hexadecimal: ...
Read MoreHow I can show JavaScript alert box in the middle of the screen?
The native JavaScript alert() box cannot be repositioned as its styling and position are controlled by the browser. To show an alert box in the center of the screen, you need to create a custom alert dialog using HTML, CSS, and JavaScript. Why Native alert() Can't Be Centered The built-in alert() function displays a browser-controlled modal that appears at a fixed position determined by the browser, typically near the top of the viewport. This position cannot be customized through CSS or JavaScript. Creating a Custom Centered Alert Box Here's how to create a custom alert that ...
Read MoreWhy does the JavaScript void statement evaluate an expression?
The JavaScript void operator evaluates an expression and always returns undefined, regardless of what the expression returns. This is useful for preventing unwanted side effects in web pages. What is the void Operator? The void operator takes any expression, evaluates it, and returns undefined. It's commonly used in links to prevent navigation while still executing JavaScript code. Syntax void expression void(expression) Example: Using void(0) in Links The most common use case is void(0) in hyperlinks to prevent page navigation: Understanding JavaScript void(0) ...
Read MoreHow can I make a browser to browser (peer to peer) connection in HTML?
Creating browser-to-browser (peer-to-peer) connections in HTML can be achieved using WebRTC technology. The PeerJS library simplifies this process by providing an easy-to-use API for establishing P2P connections. Include the PeerJS Library First, include the PeerJS library in your HTML file: Create a Peer Connection Initialize a new peer with a unique ID. PeerJS provides free public servers, so no API key is required: // Create a new peer with a unique ID var peer = new Peer('peer-' + Math.floor(Math.random() * 1000)); // Listen for incoming connections peer.on('connection', function(conn) ...
Read MoreHTML 5 video or audio playlist
HTML5 provides the onended event that fires when audio or video playback completes. This event is essential for creating video playlists, showing completion messages, or automatically loading the next media file. Basic onended Event Example The onended event allows you to execute JavaScript when media playback finishes. Here's a simple example that shows a message: Your browser does not support the video ...
Read MoreUsage of font-style property in CSS
The font-style property in CSS is used to specify whether text should be displayed in normal, italic, or oblique style. This property allows you to add emphasis to text by changing its visual appearance. Syntax font-style: normal | italic | oblique; Values normal - Default value. Text is displayed normally italic - Text is displayed in italic style (slanted) oblique - Text is displayed in oblique style (artificially slanted) Example: Basic Font Style Usage ...
Read MoreThe correct way to work with HTML5 checkbox
HTML5 checkboxes allow users to select multiple options from a list. The correct syntax uses the input element with type="checkbox". Syntax Basic Example Here's a simple checkbox form with labels: HTML5 Checkbox Example Mathematics ...
Read MoreFont size adjust of an element with CSS
The font-size-adjust CSS property enables you to adjust the x-height to make fonts more legible when fallback fonts are used. It helps maintain consistent visual font sizes across different font families. Syntax font-size-adjust: none | number; Parameters none - Default value. No font size adjustment. number - A positive number that specifies the aspect ratio (x-height divided by font size). How It Works The property calculates: adjusted font size = specified font size × (font-size-adjust value ÷ aspect ratio of actual font) ...
Read MoreHow to give a warning for Non-JavaScript Browsers?
To warn users about non-JavaScript browsers, use the tag. The HTML tag handles browsers that recognize tags but have JavaScript disabled or don't support scripting. This tag displays alternate content when JavaScript is unavailable. Syntax Content to display when JavaScript is disabled Basic Example Here's how to provide a warning message for users without JavaScript: JavaScript Warning Example document.write("Hello JavaScript!"); ...
Read MoreHow to create a line break with JavaScript?
To create a line break with JavaScript, we have three different approaches depending on your use case and HTML structure. In this article, we'll explore how to create line breaks using the tag, the newline character, and the insertAdjacentHTML() method with block elements. Each method has specific applications and benefits. Approaches to Create a Line Break with JavaScript Using tag with DOM manipulation Using newline character () Using insertAdjacentHTML() with block elements Using tag with DOM manipulation ...
Read More