5 Easy Tips to Customize Browser Alert Popups

by Vladimir Popescu
Vladimir Popescu
Vladimir Popescu
Managing Editor
Being an artist his entire life while also playing handball at a professional level, Vladimir has also developed a passion for all things computer-related. With an innate fascination... read more
Affiliate Disclosure
  • Javascript is the programming language that dictates the browser alert popup function.
  • Browser alert popups are in-browser notifications that convey messages to the user. 
  • The best way to customize the alert popup is to alter the CSS code. 
Strugling with your current browser? Upgrade to a better one: OperaYou deserve a better browser! 350 million people use Opera daily, a fully-fledged navigation experience that comes with various built-in packages, enhanced resource consumption and great design. Here's what Opera can do:

  • Easy migration: use the Opera assistant to transfer exiting data, such as bookmarks, passwords, etc.
  • Optimize resource usage: your RAM memory is used more efficiently than in other browsers
  • Enhanced privacy: free and unlimited VPN integrated
  • No ads: built-in Ad Blocker speeds up loading of pages and protects against data-mining
  • Gaming friendly: Opera GX is the first and best browser for gaming
  • Download Opera

Can you imagine your mobile phone without notifications? Notifications help you navigate the different apps on your device by giving you bits and pieces of what’s going on in those apps, and you can decide what’s important enough to pay attention to. 

There are three types of JavaScript popup boxes: the alert box, confirm box, and prompt box. This article will focus on the alert box. 

The alert box’s main aim is to get the user’s information. The alert box usually requires the user’s OK or Dismiss input to proceed. Keep reading to learn more about browser popup alerts. 

What is a browser alert?

A browser alert describes a notification sent by a website or web application. Users can receive browser alerts from websites they have subscribed to even when they’re not on the website or actively using their browser.

Before the development of mobile and computer applications, browsers were the only access to the internet, but even then, there were no notifications. The Google Chrome version 42 update marked the turning point in browser evolution. 

Browser notifications perform the same functions as mobile app notifications. However, the notifications used in browsers are known as browser alert popups or JavaScript popup boxes.  

What does JavaScript alert mean?

A JavaScript alert is a message window for users. It could vary from notifying the user of an error to other messages like a new update.

The JavaScript alerts function instructs the browser to send a modal dialog that carries a message and an OK button. 

How do I manage browser alert popups in JavaScript?  

1. Use Selenium webdriver 

  1. Press the Windows + E keys to start File Explorer.
  2. Click on This PC, right-click on a free space on the drive of your choice and create a folder called jsalert.
  3. Create an HTML file called jsalerts.html inside the jsalert folder. 
  4. Paste the code below into the file.
  5. Save the code and open the HTML file in your browser.
  6. Click each button repeatedly to see the different alerts; simple (), confirm (), and prompt (). 
<!DOCTYPE html>
    <h2>Handling JavaScript Alerts Using Selenium WebDriver</h2>
    <button id="simple" onclick="simpleAlert()">Try Simple Alert</button>
    <button id="prompt" onclick="promptAlert()">Try Prompt Alert</button>
    <button id="confirm" onclick="confirmAlert()">Try Confirm Alert</button>
    <p id="lambdaTestDemo"></p>
        function simpleAlert() {
            alert("This is how simple alert looks!");
        function confirmAlert() {
            var textToDisplay;
            if (confirm("Click Ok or Cancel!")) {
                textToDisplay = "Selenium Webdriver clicked on OK!";
            } else {
                textToDisplay = "Selenium Webdriver clicked on Cancel!";
            document.getElementById("lambdaTestDemo").innerHTML = textToDisplay;
        function promptAlert() {
            var textToDisplay;
            var pincode = prompt("Please enter your area pincode:", "560061");
            if (pincode == null || pincode == "") {
                textToDisplay = "Selenium Webdriver cancelled the prompt.";
            } else {
                textToDisplay = "Product will be delivered to " + pincode + ". Happy?";
            document.getElementById("lambdaTestDemo").innerHTML = textToDisplay;

There are four main browser alerts categories: simple, prompt, confirm, and authentication. To handle these alerts, you can use the steps above.

2. Close browser alert in JavaScript 

There are two methods for closing browser alerts in JavaScript and they are: 

  1. The close () method. The code for the close () function looks like this: 

let notification = new Notification(title, options);
// do some work, then close the notification

  1. The setTimeout function for auto-close. The code for setTimeout function looks like this: 

Expert Tip: Some PC issues are hard to tackle, especially when it comes to corrupted repositories or missing Windows files. If you are having troubles fixing an error, your system may be partially broken. We recommend installing Restoro, a tool that will scan your machine and identify what the fault is.
Click here to download and start repairing.

let notification = new Notification(title, options);
setTimeout(() => {
}, 4000);

3. Customize a JavaScript alert box with CSS

You can customize a JavaScript alert box with CSS. Using the CSS top and left properties to customize the position of the alert box.

This is what an alert box code would look like:

<div class="alert">
  <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
  This is an alert box.

W3 Schools has a very nice tutorial on how to create JavaScript alerts with CSS and that might help you a lot.

4. How to set browser alerts

JavaScript uses the alert () method to display alert boxes. The alert box pops up with a specific message and an OK button, which is used to ensure that the user gets the message. For instance, let us look at the code below for a simple JavaScript alert: 

<!DOCTYPE html> 
Alert() Method in JavaScript
 h1 {
 color: Blue;
 h2 { 
font-family: Impact; 
body { 
text-align: center;
 <h1>Welcome to JavaScript</h1>
 <h2>Alert in JavaScript</h2> 
 To display the alert message,
 click on the "Show Alert Message" button: 
<button ondblclick="myalert()">
 Show Alert Message 
 function myalert() {
 alert("This is the Alert Message!");

This code will give the following output: 

Welcome to JavaScript 

Alert in JavaScript 

To display the alert message, click on the show alert message button

Once you double-click the button, the following message will be displayed: 

This page says

This is the alert message 


5. Enable the Edge browser JavaScript alert

  1. Open your Edge browser and click on the More button (the three dots at the top right corner of the screen), scroll down the options, and click on Settings.
  2. Type JavaScript in the settings search bar.
  3. The browser will highlight all JavaScript-related settings; click the JavaScript section. 
  4. Enable the JavaScript alert by clicking the toggle next to the Allowed (recommended) option.
  5. You can use the Block or Allow options to select specific sites you want to block or allow alerts from. 

Browser alerts have revolutionized the browser experience by allowing users to keep track of their activities as they would with mobile applications.

You can receive prompts, confirm an action, or just be reminded of certain activities on a website even when you’re not actively on the site or using your browser.

I hope this article’s information has made navigating your browser alert popup easier.

You might want to look at our list of the best browsers to customize your address bar and see if you want to replace the existing one.

In the meantime, if you have any suggestions or questions, don’t hesitate to use our comments section below to let us know about them.

idee restoro Still having issues? Fix them with this tool:
  1. Download this PC Repair Tool rated Great on TrustPilot.com (download starts on this page).
  2. Click Start Scan to find Windows issues that could be causing PC problems.
  3. Click Repair All to fix issues with Patented Technologies (Exclusive Discount for our readers).

Restoro has been downloaded by 0 readers this month.

This article covers:Topics: