I have a form with 2 submit buttons. On the form tag, I put onsubmit="return foo();"
So when I click in one of the two submit buttons, I can retrieve the submit element thanks to document.activeElement in IE, Chrome, Firefox. But document.activeElement doesn't work in safari (document.activeElement return a body element instead of the submit button element).
Here my code (you can try it at https://jsfiddle.net/m6quo8rs/ ) :
<form onsubmit="foo();">
<input type="submit" id="submit_button_1" value="Submit button 1">
<input type="submit" id="submit_button_2" value="Submit button 2">
</form>
<script type="text/javascript">
function foo()
{
//Retrieve the submit button clicked thanks to document.activeElement :
console.log(document.activeElement);
}
</script>
This code works in IE, Chrome, Firefox, but doesn't work in Safari.
Have you a solution for safari ?