在我的代码中,我有以下代码行:
<input type="text" name="fname" id="first" onfocusout="firstNameHandler()">当我在HTML验证器中运行它时(出于学术目的,它是必需的),它会标记为一个问题。这是我的问题,我需要集中处理,因为我们有文本输入字段,当您写您的名字时,例如john,它会将其转换为John。只有当您不再关注所述文本输入字段时,才会发生这种情况。
因此,怎样才是正确的处理方法?
发布于 2016-09-10 19:50:19
是的,onfocusout不是可移植的,在火狐中也不起作用。对于Internet Explorer:
function isIE () { var myNav = navigator.userAgent.toLowerCase(); return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false; }
然后,由于IE9和更高版本支持onblur,但是IE8和更早版本不支持:
if (isIE () && isIE () < 9) { // is IE version less than 9 // insert code to tell the user that they are using a version of // internet explorer that doesn't work with your page // and is outdated.
}
else { // is IE 9 and later or not IE // This means that this will (probably) work // unless the user is using an extremely outdated browser // or one that doesn't support JavaScript.
}
发布于 2016-09-10 19:27:48
嗯,找到了使用onblur而不是onfocusout的解决方案,然而,我想知道的是IE的方法是什么,如果我没有弄错的话,IE在每一种可能的形式上都是特殊的。
https://stackoverflow.com/questions/39429755
复制相似问题