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?
| |
|
Welcome to KnowledgeSutra - Dear Guest | |
Javascript Alert On When Clicking A Link
Started by Amezis, Dec 16 2005 08:31 PM
2 replies to this topic
#2
Posted 17 December 2005 - 11:24 AM
The actual function in javascript itself is confirm().
The above code must appear between the <head> and </head> tags of your document.
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.
<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.
Reply to this topic

1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users














