Javascript Articles

Page 299 of 534

What is onerror() Method in JavaScript?

Abhinaya
Abhinaya
Updated on 15-Mar-2026 2K+ Views

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 More

Set a dotted line for the border with CSS

Samual Sam
Samual Sam
Updated on 15-Mar-2026 2K+ Views

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 More

How to catch exceptions in JavaScript?

Ankitha Reddy
Ankitha Reddy
Updated on 15-Mar-2026 409 Views

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 More

Usage of border-right-color property in CSS

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

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 More

How to do basic form validation using JavaScript?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 824 Views

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 More

How can we debug JavaScript using Firefox?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 3K+ Views

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 More

How can we debug JavaScript in Internet Explorer?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 278 Views

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 More

Usage of border-width property in CSS

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 158 Views

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 More

How to convert seconds to HH-MM-SS with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 4K+ Views

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 More

How to submit an HTML form using JavaScript?

Abhishek
Abhishek
Updated on 15-Mar-2026 18K+ Views

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
Showing 2981–2990 of 5,340 articles
« Prev 1 297 298 299 300 301 534 Next »
Advertisements