Add beforeNavigate callback

@kpdecker, let me know if you think this is the right direction and I'll add test/docs then.