How can I stop the browser back button using JavaScript?

前端 未结 30 4145
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 00:07

I am doing an online quiz application in PHP. I want to restrict the user from going back in an exam.

I have tried the following script, but it stops my timer.

30条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-22 01:08

    You can just put a small script and then check. It won't allow you to visit previous page.

    This is done in JavaScript.

    
    

    The window.onunload function fires when you try to visit back or previous page through browser.

提交回复
热议问题