Tinkering with this (http://www.simplemachines.org/community/index.php?topic=512029.msg3618048#new), and curious if it's possible to do something similar in the main menu button array in Subs.php. Tried adding this to the array -
'custom' => 'onclick="return confirm(\'Are you sure?\');"',
but it's ignored.
There is a way you can do it but you're not supposed to do it, really :P
If you adjust the target to be
'target' => 'http://example.com" onclick="return confirm(\'Are you sure?\');',
it should work. The surrounding " will be added normally to start the link and end the onclick.
Tried this -
'target' => 'http://www.simplemachines.org" onclick="return confirm(\'Are you sure?\');',
Shows the confirm box, but opens new blank window when click 'OK'.
And why does it require a single quote before the url, and double quote after?
Ok, it was missing a double quote at the end, now it opens the page in a new window, should be _self.
'target' => $scripturl . '?action=help" onclick="return confirm(\'Are you sure?\');"',
Bah, it's not *target*, it's the normal href attribute (target is for something else unrelated)
As for the mismatch of quotes, I did actually explain that. But I guess I can be more thorough.
When it's output, it's output as an <a href="{href goes here}"> link. You already have the surrounding ", what this is doing is exiting the " for the href, and starting a new one.
So: <a href="{href goes here}"> becomes:
<a href="http://example.com/" onclick="return confirm('Are you sure?');"> because of the quote handling.
And no, it wasn't missing a double quote.
I'll try that. Meanwhile, this works -
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'target' => '_self" onclick="return confirm(\'Are you sure?\');"',
'show' => true,
'sub_buttons' => array(
),
),
Looks like it shouldn't, but

.
Except it adds an extra " into your code that shouldn't be there. Look at the result source, you should find you have an extra " in there (for the very reason I outlined)
Works either way, so I took out the '' on the end.
'target' => '_self" onclick="return confirm(\'Are you sure?\');',
How to you put it in the 'href' field?
Same way you do anything else...
'href' => $scripturl . '?action=help" onclick="return confirm(\'Are you sure?\');',
Ok, much cleaner. Had tried that, but didn't get the quotes right.
Thx.