0

I'm modifing a project which import the next script in all pages:

 function nbb(){
   window.location.hash="";
   window.location.hash="Again-No-back-button" //chrome
   window.onhashchange=function(){window.location.hash="";}
}     

imported this way:

<body onload="nbb();"> 

remove the importation isn't a option for now, so I want to disable, unset or redefine the script because I'm using angular and if I want to go to another route like /#otherRoute this script is won't let me because go back to the root index.

I've tried with:

 window.onhashchange = undefined;

or redefine it but nothing works.

Thanks in advance.

Jose Rojas
  • 3,490
  • 3
  • 26
  • 40
  • Can you post more code or a plunker? – Srijith Jul 14 '16 at 16:43
  • @Srijith I don't have further information, the script goal is block when user wants to go back in the web page. – Jose Rojas Jul 14 '16 at 16:48
  • Do you have control over that _nbb()_ function? Perhaps instead of setting the _onhashchange_ handler, an event handler for the _[popstate](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate)_ event could be used - e.g. [this answer](http://stackoverflow.com/a/42083865/1575353) – Sᴀᴍ Onᴇᴌᴀ Mar 06 '17 at 22:08
  • the function is imported in a template which inherit others views, but I need to disable only in some views. I will try your suggestion. Thanks. @SamOnela – Jose Rojas Mar 06 '17 at 22:21

0 Answers0