In order to use SweetAlert plug-in in your website, you simply need to include two dependency files in the section of your webpage:
#Action strings demo code
See online demo and code Setting up this cool plug-in In this demo, a prompt alert is shown to take the user input before proceeding. You may perform an action there rather showing alerts. In each case, the related message is shown in next alert with an Ok button to close the alert. You can see, a user is presented with a confirmation alert with Red button to proceed or cancel the operation. You may use this alert type for giving a warning to the user before proceeding to some critical action like “deleting an account permanently” or deleting a file etc. You may show this alert after filling the form by the user and upon successful entry into the database. This function is called at the click event of the button. See a demo and code online for this alert: For example, creating an account or subscribing for updates etc. This JavaScript-based alert can be useful for some successful action by the user. You can see, instead of using “alert” keyword in the section, I just used “swal” to create a basic alert with a message and “Ok” button to close it. See a basic alert demo online by using SweetAlert: First have a look at a few demos of different alerts by using it. In this demo, I have used a plug-in, SweetAlert, which is available at the Github website. You may also see the steps to set up that plug-in for your web page after the demos. I will show you demos of fancy JavaScript alerts by using plug-ins. For that, you simply need to include the JS libraries provided by alert developers into your web pages or follow their guidelines. In order to use beautifully designed alert boxes or dialogue, you can use third party JavaScript solutions. Unfortunately, this is what JavaScript comes up with. Similarly, you may concatenate a variable with a string by using operator as shown below:Īlert(“Alert with concatenation: ” + alertstr) Creating fancy alertsĪll the alerts in above examples are using the default browser-based style that is considered boring and old-fashioned.