为什么 Internet Explorer 不允许更改输入类型?
我写了一个现代的登录表单,其中“用户名”写在一个字段中,但是是灰色的,当您单击它时,它消失并且文本也变成黑色,我还有一个“密码”,它以文本输入开头,但是当您单击它时,它应该更改为密码类型,但它仍然是文本。这个接缝似乎只出现在IE8上?为什么以及有解决方法吗?
onFocus='if (this.value == "Password"){ this.value = ""; this.type = "password";}'
I have written a modern login form where 'Username' is written in one field, but is grey, when you click it, it vanishes and also turns the text black, I also have a 'Password' on that starts as a text input, but when you click on it, it is supposed to change to a password type, but it remains text. This seams to only appear on IE8? why and is there a work around?
onFocus='if (this.value == "Password"){ this.value = ""; this.type = "password";}'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Internet Explorer 的 DOM 实现并非旨在处理动态更改的 INPUT 类型。请参阅 http://msdn.microsoft.com/en-us/library/ms534700。 .aspx.
作为解决方法,您可以隐藏密码字段,然后在文本框和密码字段之间切换可见性。
Internet Explorer's DOM implementation wasn't designed to handle dynamically changing INPUT types. See http://msdn.microsoft.com/en-us/library/ms534700.aspx.
As a workaround, you can have a hidden password field and then switch visibility between the text box and the password field.