>>Is there any way to control the history (except for going back and forth) in Javascript
\r
history.length
history.go(number)
Another location.replace() overwrites the current history item.
\r
>>if you can somehow keep track of clicking buttons back and forth and not to go on them?
\r
No. But when you go to the link to open the page with redirection to the target page, respectively, pressing back will get a page redirect and return. But I do not recommend, is irritating.
\r
There are still onunload, but it's still wrong.
\r
Of course, if you have the opportunity to expand the current story and go where it is necessary, as in the Opera, this will not help.