What's the best way to add an alert box to a link in D7 I have a link, which is rendered via the l function. It's a link which calls a function that deletes a node. Before the function is called, I want an alert box to pop up and give the user the option to 'Cancel' or 'Confirm'. Adding this as an argument to the l function works:

array('attributes' =&gt; array('onclick' =&gt; 'return confirm("Are you sure?")'))


...but is there an existing function, or something, that does a nicer job?

I'd rather not add a contrib module for such a small task.
no there is no js related function in drupal 7 that provides a functionality like that. just make sure that custom setup you have there is in your template.php