It seems like an easy solution would be to use the `locaion.hash’ javascript property when adding ‘active’ class.
Location Hash Property`