Pardeep

Pardeep

  • NA
  • 11
  • 1.8k

Chrome: Throttling history state changes

Dec 9 2019 4:49 AM
I am just changing the url when page go to particular height. but it shows me error in the chrome :Throttling history state changes to prevent the browser from hanging. after 1200 height. but it is working fine in the firefox.
  1. function myFunction() {  
  2.     var h = ($("html").scrollTop());  
  3.     if (h == 0) {  
  4.         window.history.pushState(nullnull'/');  
  5.         // console.log("0oo");    
  6.     } else if (h >= 1 && h <= 600) {  
  7.         window.history.pushState(nullnull"abc");  
  8.         // console.log("test");    
  9.     } else if (h >= 600 && h <= 1200) {  
  10.         history.pushState(nullnull'def');  
  11.         // console.log("test1");    
  12.     } else if (h >= 1200 && h <= 1800) {  
  13.         history.pushState(nullnull'ghi');  
  14.         // console.log("test2");    
  15.     } else if (h >= 1800 && h <= 2400) {  
  16.         history.pushState(nullnull'jkl');  
  17.         // console.log("test3");    
  18.     } else if (h >= 2400 && h <= 3000) {  
  19.         history.pushState(nullnull'mno');  
  20.         // console.log("test4");    
  21.     } else if (h >= 3000 && h <= 3600) {  
  22.         history.pushState(nullnull'pqr');  
  23.         // console.log("test5");    
  24.     } else if (h >= 3600 && h <= 4200) {  
  25.         history.pushState(nullnull'stu');  
  26.         // console.log("test6");    
  27.     } else {  
  28.   
  29.     }  
  30. }

Answers (2)