I suspect there is multiple ways and what is best can depend upon some additional factors.
It maybe as simple as customizing/extending the GBC button widget so that it has an onclick attribute. You can experiment using browser developer tools to add onclick="alert('here')) and seeing that the alert is triggered rather than the 4gl action.. Then you can experiment finding other functions. It will get interesting if you want to control when the button is active. You might also consider using LABEL with styles textFormat="html", sanitize="no" instead of a button.
For that last question "... where the function name can be defined as an attribute on the button element in the form definition." ...You do have the TAG attribute
http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_FSFAttributes_TAG.html which can be used to pass additional info of your choosing upto the front-end.
Reuben