Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/09/2012, 14:15
Avatar de Dradi7
Dradi7
 
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 16 años, 9 meses
Puntos: 220
Respuesta: ¿Como bloquear F5 durante un submit?

Bueno

esta es una forma de hacerlo en JavaScript con PHP tambien puedes hacerlo pero ya en PHP lo unico que harias seria que no te inserte varias veces.

Código Javascript:
Ver original
  1. if(window.attachEvent){
  2.         document.attachEvent("onkeydown",function(){
  3.             switch (event.keyCode) {
  4.                 case 116 : //F5 button
  5.                     event.returnValue = false;
  6.                     event.keyCode = 0;
  7.                     return false;
  8.                 case 82 : //R button
  9.                     if (event.ctrlKey) {
  10.                         event.returnValue = false;
  11.                         event.keyCode = 0;  
  12.                         return false;
  13.                     }
  14.             }
  15.         });
  16.     }else{
  17.         document.addEventListener("keydown",function(){
  18.             switch (event.keyCode) {
  19.                 case 116 : //F5 button
  20.                     event.returnValue = false;
  21.                     event.keyCode = 0;
  22.                     return false;
  23.                 case 82 : //R button
  24.                     if (event.ctrlKey) {
  25.                         event.returnValue = false;
  26.                         event.keyCode = 0;  
  27.                         return false;
  28.                     }
  29.             }
  30.         });
  31.     }

Con esto deshabilitamos el F5 y la Tecla Ctr + R (bueno en realidad la R)
__________________
La clave de todo triunfador es eliminar todas sus excusas y sus limitaciones