Clear browser history

前端 未结 1 2071
抹茶落季
抹茶落季 2020-12-11 11:44

I wrote the following code to clear the browser history and it\'s working correctly in Internet Explorer but it does not work in Mozilla Firefox. How can I solve this proble

相关标签:
1条回答
  • 2020-12-11 12:00
    1. Do NOT try to break the back button
    2. Instead on the page you want not to return to use location.replace(url)

    Also your code can be vastly simplified - but be aware it does not CLEAR the history. You cannot clear the history, only keep a page from getting into the history or as you try, break the back button

    function DisablingBackFunctionality() {
    // get the query string including ?
      var passed =window.location.search; 
    // did we receive ?X
      if (passed && passed.substring(1) =="X") { 
    // if so, replace the page in the browser (overwriting this page in the history)
        window.location.replace("http://localhost:8085/FruitShop/"); 
      }
    }
    
    0 讨论(0)
提交回复
热议问题