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 299 of 534
What is onerror() Method in JavaScript?
The onerror event handler was the first feature to facilitate error handling in JavaScript. The error event is fired on the window object whenever an exception occurs on the page. Syntax window.onerror = function(message, source, lineno, colno, error) { // Handle the error return true; // Prevents default browser error handling }; Parameters The onerror handler receives five parameters: message: Error message source: URL of the script where error occurred lineno: Line ...
Read MoreSet a dotted line for the border with CSS
To set a dotted line for the border in CSS, use the border-style property with the value dotted. This creates a border made up of small dots around the element. Syntax border-style: dotted; Example Here's how to create a dotted border using CSS: .dotted-border { border-width: 3px; ...
Read MoreHow to catch exceptions in JavaScript?
To catch exceptions in JavaScript, use try...catch...finally. JavaScript implements the try...catch...finally construct as well as the throw operator to handle exceptions. You can catch programmer-generated and runtime exceptions, but you cannot catch JavaScript syntax errors. Syntax try { // Code that may throw an exception } catch (error) { // Handle the exception } finally { // Optional - always executes } Example: Basic Exception Handling Here's a simple example demonstrating exception catching: ...
Read MoreUsage of border-right-color property in CSS
The border-right-color property sets the color of an element's right border. It works independently of other border properties and allows you to customize just the right border color while leaving other borders unchanged. Syntax border-right-color: color | transparent | inherit; Values color - Any valid CSS color (hex, RGB, HSL, color names) transparent - Makes the border transparent inherit - Inherits the color from parent element Example: Basic Usage .demo { ...
Read MoreHow to do basic form validation using JavaScript?
JavaScript provides a way to validate form data on the client's computer before sending it to the web server. This improves user experience by catching errors immediately and reduces server load. Basic form validation includes checking that all mandatory fields are filled in and that data meets specific format requirements. It requires looping through each field in the form and validating the data. Basic Validation Methods Form validation typically checks for: Empty required fields Data format (email, phone, zip code) Data length constraints ...
Read MoreHow can we debug JavaScript using Firefox?
In this tutorial, we will learn to debug JavaScript code using the Firefox web browser. Debugging helps us identify and fix unknown bugs and errors in our code. Even experienced programmers encounter situations where code works fine one day but suddenly crashes the next. Don't worry if your code crashes — once you learn debugging techniques, you can fix most bugs quickly and efficiently. Let's start by creating an example with a deliberate bug to demonstrate the debugging process. Example Code with Bug In this example, we'll create a simple string comparison tool that takes two input ...
Read MoreHow can we debug JavaScript in Internet Explorer?
Debugging JavaScript in Internet Explorer requires enabling built-in error reporting and using developer tools. While Internet Explorer is now legacy, understanding these techniques helps with maintaining older applications. Enabling Error Notifications By default, Internet Explorer shows a small error icon in the status bar when JavaScript errors occur. This icon is easily missed, so you can enable automatic error dialogs. To enable automatic error notifications: Open Internet Explorer Go to Tools → Internet Options → Advanced tab Check "Display a notification about every script error" Click OK to save changes ...
Read MoreUsage of border-width property in CSS
The border-width property sets the thickness of an element's border, not the color. It defines how wide the border should be around an element. Syntax border-width: value; Values The border-width property accepts the following values: Length values: px, em, rem, etc. (e.g., 2px, 1em) Keywords: thin, medium, thick Multiple values: Define different widths for each side Example: Basic Border Width .border-example { ...
Read MoreHow to convert seconds to HH-MM-SS with JavaScript?
In this tutorial, we will learn to convert seconds to Hours, Minutes, and Seconds (HH:MM:SS) format in JavaScript. Converting seconds to a readable time format is essential for displaying durations, timers, or elapsed time in web applications. JavaScript provides several approaches to achieve this conversion. Using the toISOString() Method The toISOString() method is one of the simplest approaches to convert seconds into the standard HH:MM:SS format. This method creates a Date object and extracts the time portion. Syntax var calculatedTime = new Date(null); calculatedTime.setSeconds(seconds); var newTime = calculatedTime.toISOString().substr(11, 8); Example The ...
Read MoreHow to submit an HTML form using JavaScript?
In this tutorial, we will learn how to submit an HTML form using JavaScript. JavaScript provides multiple approaches to handle form submission, from direct programmatic submission to validation-based submission with user feedback. We will discuss two main methods for submitting HTML forms: Using the Form submit() Method Using Manual Validation Let us explore both methods with practical examples. Using the Form submit() Method The submit() method programmatically submits a form without requiring user interaction with the submit button. This method takes no parameters and returns no value—it ...
Read More