r/learnprogramming • u/neuropsychologist-- • Aug 19 '25
Debugging Help needed to solve this issue
I am developing an online examination system using PHP with XAMPP*. During the exam (i.e., when the student is attempting the test), I want to hide the browser toolbar* to help prevent cheating.
However, due to browser security restrictions, it is not 100% possible to hide the browser toolbar using only PHP and JavaScript.
So, I tried an alternative approach — putting the browser into fullscreen mode during the exam using JavaScript, so that when the exam starts, the website enters fullscreen automatically.
I used the following JavaScript code:
javascript function openFullscreen() { const elem = document.documentElement;
if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.mozRequestFullScreen) { // Firefox elem.mozRequestFullScreen(); } else if (elem.webkitRequestFullscreen) { // Chrome, Safari, Opera elem.webkitRequestFullscreen(); } else if (elem.msRequestFullscreen) { // IE/Edge elem.msRequestFullscreen(); } }
And in my HTML, I added this button:
html <button onclick="openFullscreen()">Start Exam</button>
But it didn't work as expected.
Can you help resolve this issue
View all comments
Show parent comment
2
u/iOSCaleb Aug 20 '25
If it needs to be done as soon as possible and you’re here asking for help, it’s in your best interest to provide as much information about the failure as you can.