DEV Community

Dhiman_aman
Dhiman_aman

Posted on

2

How to add window alert on screen or Sweet Alert ?

Use Library

  • Sweet Alert
https://sweetalert.js.org/guides/
Enter fullscreen mode Exit fullscreen mode
  • Add the CDN link <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.0/sweetalert.min.js"></script>

Complete Code

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Sweer Alert</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.0/sweetalert.min.js"></script>
  </head>
  <body>
    <center>
      <h1>Sweet Alert</h1>
      <p>
        Link :
        <a href="https://sweetalert.js.org/guides/" target="_blank">
          Sweet Alert Website</a
        >
      </p>
      <button onclick="alertFunction()">Alert Function</button>
    </center>
    <script>
      alertFunction = () => {
        swal("Sweet Alert", "on Click function ", "success", {
          button: "OK",
        });
      };
    </script>
  </body>
</html>

Enter fullscreen mode Exit fullscreen mode

Image description

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay