Web Development Articles

Page 352 of 801

How do we use throw statement in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 812 Views

In this tutorial, we will learn to use the throw statement in JavaScript. The "throw" is a reserved keyword in JavaScript that allows programmers to create user-defined exceptions. Every programmer makes errors, and sometimes users enter invalid input that causes exceptions. While JavaScript has built-in exceptions like arithmetic and index out-of-bound exceptions, programmers often need to create custom exceptions using the throw statement inside try...catch blocks. Below, we have given different examples of using the throw keyword in JavaScript. Using the throw keyword to create exception In this section, we will learn to create simple user-defined ...

Read More

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

Change the color of right border with CSS

George John
George John
Updated on 15-Mar-2026 244 Views

The border-right-color CSS property allows you to change the color of an element's right border specifically, without affecting the other borders. Syntax border-right-color: color; Parameters The color value can be specified using: Color names: red, blue, green Hex values: #FF0000, #00FF00 RGB values: rgb(255, 0, 0) HSL values: hsl(0, 100%, 50%) Example: Basic Right Border Color .demo { border: 3px solid black; ...

Read More

How to catch exceptions in JavaScript?

Ankitha Reddy
Ankitha Reddy
Updated on 15-Mar-2026 416 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

Change the Color of Link when a Mouse Hovers

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 1K+ Views

To change the color of a link when a mouse pointer hovers over it, use the CSS :hover pseudo-class. This creates an interactive effect that provides visual feedback to users. Syntax a:hover { color: desired-color; } Basic Example Here's how to change a link's color on hover: a { ...

Read More

How to do basic form validation using JavaScript?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 830 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 280 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

Set width between table cells with CSS

Samual Sam
Samual Sam
Updated on 15-Mar-2026 319 Views

The border-spacing CSS property controls the distance between adjacent table cells. It only works when border-collapse is set to separate (the default value). Syntax border-spacing: horizontal vertical; border-spacing: value; /* same for both directions */ Parameters The property accepts one or two length values: One value: Sets equal spacing horizontally and vertically Two values: First value for horizontal spacing, second for vertical spacing Example: Basic Border Spacing table.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
Showing 3511–3520 of 8,010 articles
« Prev 1 350 351 352 353 354 801 Next »
Advertisements