Skip to content

JavaScript Popup Alert on Link Click

Reading Time: < 1 minute

JavaScript is a powerful tool to build a framework efficiently. We sometimes need a popup alert on a link before it goes to another page or URL.

Popup Alert

We can create alerts with Javascript, which has default inbuilt functionality. We will make a simple function to open an alert when a link or button is clicked.

Step#1 Create a JavaScript function that shows an Alert

<script type="text/javascript">
function confirm_alert(node) {
    return confirm("Are you sure to continue?");
}
</script>

Step#2 Call JavaScript function in Link Click Event

<a href="https://8subjects.com" onclick="return confirm_alert(this);">Click Here</a>
See also  Query Scopes in laravel

Leave a Reply