Differenze tra le versioni di "Programmazione:Java/Javascript per il controllo del tasto MAIUSC"
(Creata pagina con '<script language="JavaScript" src="js/jscapslock.js"></script> <script type="text/javascript"> function showHide(layerid){ if (document.getElementById(layerid).style.visibili…') |
|||
Riga 1: | Riga 1: | ||
+ | <code javascript> | ||
<script language="JavaScript" src="js/jscapslock.js"></script> | <script language="JavaScript" src="js/jscapslock.js"></script> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
Riga 11: | Riga 12: | ||
</script> | </script> | ||
− | + | </code> | |
{code} | {code} |
Versione delle 11:15, 5 ott 2009
<script language="JavaScript" src="js/jscapslock.js"></script>
<script type="text/javascript">
function showHide(layerid){
if (document.getElementById(layerid).style.visibility != "hidden"){
document.getElementById(layerid).style.visibility = "hidden"
}
else{
document.getElementById(layerid).style.visibility = "visible"
}
}
</script>
{code} onkeypress="capsDetect(event);" {code}
{code}
<button style="width:74;height:20;font-size:10;border:1px outset #ffffff;" onclick="showHide('box2')">Ok</button>
js/jscapslock.js": function capsDetect( e ) { if( !e ) { e = window.event; } if( !e ) { MWJ_say_Caps( false ); return; } //premuto il maiusc var theKey = e.which ? e.which : ( e.keyCode ? e.keyCode : ( e.charCode ? e.charCode : 0 ) ); //premuto il tasto shift var theShift = e.shiftKey || ( e.modifiers && ( e.modifiers & 4 ) ); //AND //se maiusc, guarda che non sia premuto lo shife. Se non maiusc, guarda che sia premuto MWJ_say_Caps( ( theKey > 64 && theKey < 91 && !theShift ) || ( theKey > 96 && theKey < 123 && theShift ) ); } function MWJ_say_Caps( oC ) { if( typeof( capsError ) == 'string' ) { if( oC ) { showHide('box2'); } } else { capsError( oC ); } }
function showHide(layerid){ if (document.getElementById(layerid).style.visibility != "hidden"){ document.getElementById(layerid).style.visibility = "hidden" } else{ document.getElementById(layerid).style.visibility = "visible" } }
{code}