prompt box in jQuery

Hi,
When a user clicks on a link I want a prompt box to appear asking the if they are sure they want to proceed.  If they click 'OK', they are taken to the destination of the link.  If they click 'Cancel', they remain on the same page.  What is the jQuery syntax for this?

Thanks.
deafpandaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tomarse111Commented:
Not sure on jquery syntax but the basic javascript syntax would be
<script type="text/javascript">
	function check(){
		if(confirm('Do you really want to go to this link?')){
			window.location='http://yourlinkhere.com';
		}
	}
</script>
            
<a href="javascript:void(0)" onclick="check();">link</a>

Open in new window

0
Tomarse111Commented:
Or even this (but im not sure if this one works in every browser):
<script type="text/javascript">
	function check(){
		if(confirm('Do you really want to go to this link?')){
			return true
		}
		return false
	}
</script>
            
<a href="http://yourlinkhere.com" onclick="return check();">link</a>

Open in new window

0
Albert Van HalenAnalyst developerCommented:
Have a look at jquery.UI.
There is the dialog which will suit your needs
See this link for some functional demos (http://dev.jquery.com/view/trunk/ui/demos/functional/#ui.dialog)
For documentation see (http://docs.jquery.com/UI/Dialog)
0
deafpandaAuthor Commented:
AlbertVanHalen:

Thanks for your advice.  I'm having trouble getting the following code to work - can you tell me where I'm going wrong?  Clicking a link with the id of "delete_entry" should display a dialog box (from a div with id "dialog_delete").  INstead it just acts as a normal link.
$(document).ready(function(){
	('#delete_entry').click(function(){
		$('#dialog_delete').dialog();
		return false;
	});
});

Open in new window

0
Albert Van HalenAnalyst developerCommented:
You forgot the $ in line 2. Use :  $('#delete_entry').click(function(){
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.