How to completly disable back button of a browser while taking online exam?

前端 未结 6 879
醉话见心
醉话见心 2020-12-15 11:46

In online examination once candidate has clicks on start button i dont want to allow him to go back (to previous pages) and he should be in same page if he do any activities

6条回答
  •  Happy的楠姐
    2020-12-15 12:27

    While you can prevent the back button, you can't prevent the user from disabling JS while he takes the exam. This makes JS approaches practically useless.

    Assuming that previous pages are questionaires, I suggest that once the user moves away from the page, any further access to that page will be invalid. This can easily be done using a server-side language and a database to track pages visited by the user.

    Do note that some browsers do a "refresh" on the previous page when doing a back, while others load them from the cache. The latter will make the page still accessible even if you marked it inaccessible on the server. What you can further do is to invalidate any action taken on that page once it has been deemed invalid for access. That way, even if the user had a copy of that page, he can't do anything with it.

    Besides, it's an exam, and JS is a bad place to put some exam logic as it can easily be inspected and modified. You should leave everything on the server instead.

提交回复
热议问题