views:

78

answers:

1

I need to create some kind of JS onclick that will run a php mail script that emails a page with broken content.

Would it be best to run a normal javascript onclick that calls a php file which is hidden, grabs the referring url and emails it?

I would also like a message confirming the click, then disable it.

Is there anything like this available?

+4  A: 

This will create onClick handler for your link, and action will be done in case user will accept confirm message.

var onClickHandler = function() {
   if (confirm("Are you sure?")) {
       $.post("your_php_mail_script.php", {broken_url: document.location});
   }
};

$("#your_link_id").bind("click", onClickHandler);

And that is all. In your script you'll get broken url as POST parameter ($_POST['broken_url']). This will be done asynchronous. I can't understand what you want to disable and after what action.

Andrew Dashin