How can I use window.history.pushState 'safely'

前端 未结 3 1525
梦谈多话
梦谈多话 2021-01-31 05:01

I would like to use the window.history.pushState() function in supporting browsers. Unfortunately I\'m getting an error on Firefox:

TypeError

3条回答
  •  余生分开走
    2021-01-31 05:29

    [try-catch] tag implies what you know the answer already... (is there anything more specific?) The other possibitity is to check if ( history.pushState ) history.pushState( {}, document.title, location.href );

提交回复
热议问题