I tried this and result is that both the onclick and href are "executed": just have a look in your browsers history. One step back you'll find thepage with #b and two steps back the page before the click.
Let's take a step back, and please explain how #a could be "missing". If this is a static HTML page, then the contents are well-known and there's no need for a fallback. If it's a generated page where #a is dynamically generated based upon a condition, that same condition can be used to correctly target the link. Rather than trying to trick HTML into doing something it wasn't designed for, let's take a look at the bigger picture and solve it in a conventional manner.