【问题标题】:Why would Internet explorer not allow changing the type of an input?为什么 Internet Explorer 不允许更改输入的类型?
【发布时间】:2011-08-15 21:32:10
【问题描述】:

我编写了一个现代登录表单,其中“用户名”写在一个字段中,但是是灰色的,当您单击它时,它会消失并且文本也会变黑,我还有一个“密码”,开头为文本输入,但是当您单击它时,它应该更改为密码类型,但它仍然是文本。这似乎只出现在 IE8 上?为什么以及是否有解决方法?

onFocus='if (this.value == "Password"){ this.value = ""; this.type = "password";}'

【问题讨论】:

标签: html internet-explorer input passwords


【解决方案1】:

Internet Explorer 的 DOM 实现并非旨在处理动态变化的 INPUT 类型。见http://msdn.microsoft.com/en-us/library/ms534700.aspx

作为一种解决方法,您可以设置一个隐藏的密码字段,然后在文本框和密码字段之间切换可见性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-28
    • 2017-04-03
    • 2011-11-03
    • 1970-01-01
    • 2020-05-16
    • 2018-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多