disable F5 key and Back

  • akash
  • Newbie
  • Newbie
  • akash
  • Posts: 5

Post 3+ Months Ago

I want to disable F5 key and BACK key so that user cannot move to previous page. what should i do using javascript??
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • CrAzY_J
  • Beginner
  • Beginner
  • CrAzY_J
  • Posts: 35

Post 3+ Months Ago

the F5 key i can disable but what do you mean with BACK?
the button on the browser ?! if so then it's not possible.
at least not with Javascript
  • akash
  • Newbie
  • Newbie
  • akash
  • Posts: 5

Post 3+ Months Ago

Yes BACK button on browser. I had attended an online exam in which a msgbox was display when BACK button was clicked. I dont know if the coding is done in some other language but the msgbox popped up very quickly as soon i pressed the BACK button
  • CrAzY_J
  • Beginner
  • Beginner
  • CrAzY_J
  • Posts: 35

Post 3+ Months Ago

i can only make a msgbox pop up on F5 click.
sorry :P
  • arfinator
  • Graduate
  • Graduate
  • arfinator
  • Posts: 121
  • Loc: Phoenix, AZ

Post 3+ Months Ago

dont know if your still looking for this, but I imagine you could use like a javascript:history.go(-1) and then make an alert.

Just a suggesstion...
  • Mas Sehguh
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1853

Post 3+ Months Ago

akash wrote:
I want to disable F5 key and BACK key so that user cannot move to previous page. what should i do using javascript??


This is always the wrong solution. Why do you think you need to do this?
  • ScienceOfSpock
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1892
  • Loc: Las Vegas

Post 3+ Months Ago

I have to agree with Sam. If you need to disable refresh or the back button, then your site is programmed wrong or you are trying to do something in a browser which would be better off somewhere else (flash or VB).

Now, all that aside, I can suggest using javascript's location.replace() function to get rid of the back button (only for your site). If you are using strictly html and javascript, that's the way to go. If you are using php or asp or cgi to process forms, then you need to rewrite your scripts to handle the back button or refresh instead of trying to prevent them.
  • fyndhern
  • Novice
  • Novice
  • User avatar
  • Posts: 32
  • Loc: Turkey | ANKARA

Post 3+ Months Ago

akash wrote:
I want to disable F5 key and BACK key so that user cannot move to previous page. what should i do using javascript??

Why do you need to disable F5 and back ? There will be a major problem.
  • himansh_raj
  • Born
  • Born
  • himansh_raj
  • Posts: 2
  • Loc: India

Post 3+ Months Ago

to disable F5 and back button add following code
<script>
window.history.forward(1);
document.attachEvent("onkeydown", my_onkeydown_handler);
function my_onkeydown_handler()
{
switch (event.keyCode)
{

case 116 : // 'F5'
event.returnValue = false;
event.keyCode = 0;
window.status = "We have disabled F5";
break;
}
}
</script>
  • mohan
  • Born
  • Born
  • mohan
  • Posts: 1

Post 3+ Months Ago

thanks a lot for the script himansh_raj.

I have added to my html pages and its working.

Great job.
  • Prime
  • Professor
  • Professor
  • User avatar
  • Posts: 935
  • Loc: Liverpool

Post 3+ Months Ago

It's very simple to get around this solution by disabling javascript in your browser window. You need to validate this on the server side if you hope to make it fool proof.

Cheers, Prime ... :D
  • onlyican.com
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1589
  • Loc: Hants, UK

Post 3+ Months Ago

I would just like to comment.

I build a form using HTM / PHP
The form goes through about 9 pages.

For some reason, when you click back in IE, it sometimes messes up.

OK, I admit, I was on the website clicking back, forward, back, refresh
After about 5 minutes I managed to break it.

But FF handles it OK.

Also for Payment Process or Orders, disabling refresh and Back Button would help.
  • websquad66
  • Novice
  • Novice
  • User avatar
  • Posts: 15

Post 3+ Months Ago

This may be a little radical, but use BrowserBob to create a customized browser that would work only with your application, and then require the folks that take that application to use your customized application.

I really don't know anything about BrowserBob, but there is a write up about it in the current PC Magazine, and their website is http://www.browserbob.com/.
  • camperjohn
  • Guru
  • Guru
  • User avatar
  • Posts: 1127
  • Loc: San Diego

Post 3+ Months Ago

Disable back is easy. You need your webpage A to go to a temporary page B that does a javascript forward to C. When the user is on page C and hits his back button, it goes back to B, which then goes forward again to C.

The second time through, you could always go to D instead of to C, your choice.

Make some experiements, but it is possible.

Also investigate "Post" and javascript Submit to disable the back button.

Post Information

  • Total Posts in this topic: 14 posts
  • Users browsing this forum: No registered users and 82 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.