Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Javascript Alert On When Clicking A Link


2 replies to this topic

#1 Amezis

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 535 posts
  • Location:Oslo, Norway

Posted 16 December 2005 - 08:31 PM

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?

#2 electriic ink

    "Britons never never shall be slaves." As true now as it was in 1740.

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPip
  • 1,262 posts
  • Gender:Male
  • Location:Heaven
  • Interests:Promotion: Aug 4 2005 8.24pm BST
  • myCENT:74.43

Posted 17 December 2005 - 11:24 AM

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.

#3 Amezis

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 535 posts
  • Location:Oslo, Norway

Posted 19 December 2005 - 01:52 PM

Thanks alot ;)




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users