How can i NOT trigger window.onhashchange on certain clicks?

How can i NOT trigger window.onhashchange on certain clicks?

I have 2 buttons -  A and B. On clicking A the hashtag changes and i want to call the window.onhashchange function. But, on clicking B, i am manually appending hashtag to the URL. In the later case, i don't want window.onhashchange to be triggered. I have searched a lot. Maybe my fundamentals are not that clear.
Please help me out here.