Front End Technology Articles

Page 335 of 652

How to test if a JavaScript cookie has expired?

mkotla
mkotla
Updated on 15-Mar-2026 3K+ Views

To test if a JavaScript cookie has expired, you need to check if the cookie exists or returns null. When a cookie expires, the browser automatically removes it, so attempting to access it will return null or undefined. Using document.cookie (Vanilla JavaScript) The most straightforward approach is to create a helper function that checks if a cookie exists: function getCookie(name) { const cookies = document.cookie.split(';'); for (let cookie of cookies) { const [cookieName, cookieValue] = cookie.trim().split('='); ...

Read More

How I can set the width and height of a JavaScript alert box?

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 4K+ Views

JavaScript's native alert() function creates a browser-controlled dialog box whose size cannot be customized. To set the width and height of an alert box, you need to create a custom alert dialog using HTML, CSS, and JavaScript. Why Native alert() Cannot Be Resized The browser's built-in alert() function creates a modal dialog with fixed dimensions determined by the browser and operating system. These native alerts cannot be styled or resized using CSS or JavaScript. Creating a Custom Alert Box Here's how to create a customizable alert box with specific width and height dimensions using jQuery: ...

Read More

How I can show JavaScript alert box in the middle of the screen?

Giri Raju
Giri Raju
Updated on 15-Mar-2026 2K+ Views

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 More

How to customize the position of an alert box using JavaScript?

mkotla
mkotla
Updated on 15-Mar-2026 3K+ Views

To customize the position of an alert box, you need to create a custom alert since the native JavaScript alert() function cannot be positioned. We can build a custom alert box using HTML, CSS, and JavaScript, then control its position using CSS properties like top and left. Creating a Custom Alert Box The native alert() box position is controlled by the browser and cannot be customized. Instead, we create a custom modal dialog that mimics an alert box behavior. Example: Custom Positioned Alert Here's how to create a custom alert box with customizable positioning: ...

Read More

How to center the JavaScript alert message box?

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

In this tutorial, we will learn to center the JavaScript alert box. In JavaScript, an alert box is useful to show users some message, information, warning, success, etc. Let's understand it by real-world example when you open any website on the web browser and start to authenticate by entering your username and password. When you click the submit button, it gives a message in an alert box like the password should be 8 or more characters, or sign in successfully. Users can create the alert box using JavaScript's alert() method. Unfortunately, the default alert box doesn't allow us to ...

Read More

What is the difference between void, eval, and the Function constructor in JavaScript?

usharani
usharani
Updated on 15-Mar-2026 451 Views

JavaScript provides three distinct features for executing and manipulating code: void, eval(), and the Function constructor. Each serves different purposes and has unique characteristics. The void Operator The void operator evaluates an expression and always returns undefined. It's commonly used to prevent unwanted return values or create undefined values explicitly. Syntax void expression void(expression) Example // Basic void usage console.log(void 0); ...

Read More

Why does the JavaScript void statement evaluate an expression?

Giri Raju
Giri Raju
Updated on 15-Mar-2026 157 Views

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 More

How can I stop a video with JavaScript in Youtube?

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

In this tutorial, we will learn to stop a video with JavaScript on YouTube. Using the 'iframe' HTML element, we can easily embed the YouTube videos on our application. It is a video player in HTML 5 and has many attributes that users can use according to their needs. In some cases, it happens that you want to create a custom pause or stop button for the embedded YouTube video. Customized buttons are always pretty rather than default ones, making UI pretty. So, we will learn two different methods to create the custom stop button for the YouTube ...

Read More

How to create and apply CSS to JavaScript Alert box?

Arpit Anand
Arpit Anand
Updated on 15-Mar-2026 8K+ Views

The standard alert box in JavaScript does not provide the option to apply CSS. To style your alert box, you need to create a custom one first. The custom alert box will be created using jQuery and styles will be applied to CSS. Why Custom Alert Boxes? JavaScript's built-in alert() function creates browser-native dialogs that cannot be styled. Custom alert boxes give you complete control over appearance, animations, and user experience. Example You can try to run the following code to learn how to create and apply CSS to alert box: ...

Read More

How to check if a variable is an integer in JavaScript?

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

In this tutorial, we will learn to check if a variable is an integer in JavaScript. Before we solve the problem, we must have a problem. We can ask ourselves, "why do we need to check if the variable is an integer?". Let's understand the answer using a single example. Suppose, we are taking the value from the user using the input text box. It returns the values in the string format, and now think that we are adding values. Will we get the correct result? Obviously, not. So, in such cases, we need to check if the variable is ...

Read More
Showing 3341–3350 of 6,519 articles
« Prev 1 333 334 335 336 337 652 Next »
Advertisements