Click to See Complete Forum and Search --> : Do not allow user to refresh page


luigiwong
10-30-2007, 08:30 AM
I'm developing a Perl CGI script that runs some processes on the server and generates a HTML page to show the processing results. Is there any way to prevent the user from refreshing the page after the page is loaded? I do not want the user to refresh the page, because the processes will be repeated again. I need to show some warning message if the user refreshes the page. Please help... Thanks.

Sixtease
10-30-2007, 01:12 PM
I guess I'd hide the page behind another page (like adding a layer between it and the user)... Say your page is called timeconsuming.pl. I'd make another page - say index.pl, where I'd check for a cookie on the user side. If that cookie was not there, then I'd run the time-consuming script, displayed its contents and sent the user the cookie. If that cookie was already present, I'd output nothing.

I'm not sure if reloading would then cause a blank page to be shown or the previous page to stay but even if the blank page showed up, the user could hit the back button (which could even be done by javascript, couldn't it? But that would rather be a misfeature). Or you could cache the results for users with keys being stored in the cookie...

Update: Or maybe there's an easy JavaScript solution if there is an event for refreshing or navigating to the same page again... I suggest you ask in the JavaScript forum.