Salve a tutti
ho la necessità di disabilitare il tasto F5
uso la seguente procedura
<%
brow=Request.ServerVariables("http_user_agent")
if instr(brow,"MSIE")>0 then tk="MS" else tk="FF" end if
got=tk+"cancelRefresh()"
%>
<html>
<head>
<title>prova</title>
<script language="JavaScript">
function MScancelRefresh(){
if (document.all){
if (event.keyCode == 116){
alert('Il Tasto [F5] è stato disattivato!');
{
event.keyCode = 0;
event.returnValue = false;
event.cancelBubble = true;
return false;
}
}
}
}
function FFcancelRefresh(who) {
function __keyPress(evt) {
var result = true;
if(evt.which == 116)
alert('Il Tasto [F5] è stato disattivato!');
result = false;
return result;
};
if(!who)
who = window;
if(who.document && who.document.captureEvents) {
who.document.captureEvents(Event.KEYDOWN);
who.document.onkeydown = __keyPress;
};
}
function pagina1() {
x=document.mail
y=mail
txt=x.newcart.value
rei=y.mail
if (txt=='' || txt=='Nuova Cartella') {
x.newcart.value=""
document.mail.newcart.focus();
alert("Inserire il Nome della Nuova Cartella");
return (false);
}
var checkOK = "0123456789abcdefghijklmnopqrstuvwxyz _ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var checkStr = txt;
var allValid = true;
var decPoints = 0;
var allNum = "";
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
allNum += ch;
}
if (!allValid)
{
alert("Inserire solo caratteri alfanumerici nel nome della Tabella!\n Il carattere '"+ch+"' non può essere accettato dal Sistema");
x.newcart.value=""
rei.focus();
return (false);
}
location="creatabella.asp?etc etc etc"
}
</script>
</head>
<body onkeydown="<%=got%>">
<form action="java-script:void(0)" name="mail" onsubmit="return pagina1()">
<input type="text" name="newcart" value="Nuova Cartella" size="15">
<button type="submit">crea</button>
</form>
</body>
</html>
disabilita F5 perfettamente sia su IE che su FF e Chrome
problema: su FF e Chrome non si riesce a scrivere sul campo input mentre su IE funziona tutto perfettamente![]()