Jump to content
xisto Community
Amezis

Javascript Alert On When Clicking A Link

Recommended Posts

Basically, I want that a message box pops up when clicking on a specific link. The message box will ask "Are you sure you want to continue?" and then there are two buttons Yes or No / Ok or Cancel.Could someone give a code for it?

Share this post


Link to post
Share on other sites

The actual function in javascript itself is confirm().

 

<script type="text/javascript">

<!--

function queryAction() {

 var confirmmessage = "Are you sure you want to continue?";
 var goifokay = "http://site.com/process.php";
 var cancelmessage = "Action Cancelled";

 if (confirm(confirmmessage)) {

     window.location = goifokay;

 } else {

      alert(cancelmessage);

 }

}

//-->

</script>

 

The above code must appear between the <head> and </head> tags of your document.

 

<a href="#" onClick="queryAction()"> Click Here! </a>

 

If you place the above code between the <body> and </body> of your document, a link will appear and when you click on it the confirm message will appear.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.