function getFocus(elementToFocus) { // place the id below of the field you want to have focus upon page load var focusHere = document.getElementById(elementToFocus); focusHere = focusHere.focus(); } function startup() { var revealer = document.getElementById("revealer"); revealer.addEventListener("mousedown", function(){ if (isIE() == 0) { $("#password").attr({type:"text"}); } }) revealer.addEventListener("mouseup", function(){ if (isIE() == 0) { $("#password").attr({type:"password"}); var val = $("#password").val(); $("#password").focus(); $("#password").val(""); $("#password").val(val); } }) revealer.addEventListener("touchstart", function(){ if (isIE() == 0) { $("#password").attr({type:"text"}); } }) revealer.addEventListener("touchend", function(){ if (isIE() == 0) { $("#password").attr({type:"password"}); var val = $("#password").val(); $("#password").focus(); $("#password").val(""); $("#password").val(val); } }) var pw_group = document.getElementById("bloc_password"); pw_group.addEventListener("mouseout", function(){ if (isIE() == 0) { $("#password").attr({type:"password"}); } }) } function isIE() { var ieVersion = /*@cc_on (function() {switch(@_jscript_version) {case 1.0: return 3; case 3.0: return 4; case 5.0: return 5; case 5.1: return 5; case 5.5: return 5.5; case 5.6: return 6; case 5.7: return 7; case 5.8: return 8; case 9: return 9; case 10: return 10;}})() || @*/ 0; return ieVersion ; }