【问题标题】:IE8 Password field showing entered value instead of showing asterisksIE8 密码字段显示输入的值而不是显示星号
【发布时间】:2013-09-05 09:57:24
【问题描述】:

在我的网站中,密码字段显示输入的值,而不是显示星号符号。这适用于所有其他浏览器。 IE7 和 IE9 也可以。仅在 IE8 中我没有得到它。任何帮助将不胜感激。

参考:只需检查网站并点击登录,就会出现登录框,您可以检查该密码字段的问题。

<input type="password" name="password" id="password" value="Password" 
onblur="if(this.value == '') { this.style.color='#bbb'; this.value='Password'; this.type='text'} 
else {this.type='password';}" 
onfocus="if (this.value == 'Password') {this.style.color='#000'; this.value=''; this.type='password'} else {this.type='password';}" style="color: rgb(0, 0, 0);">

【问题讨论】:

  • @BenFortune 我不想让你登录,如果你只点击那个按钮就会出现一个弹出窗口,你可以看到问题
  • 您在 IE 的第 291 行有错误..
  • 您的实际站点上有&lt;input type="text" name="password"。您可能想尝试使用 type="password",然后使用真正的占位符 polyfill 脚本而不是内联 JavaScript 废话。
  • @DipeshParmar — this 是 JavaScript 非常基础的部分。 IE 确实支持它。
  • @ManigandanArjunan 为什么要将 this.type 设置为模糊和焦点?直接在你的标签中设置 type="password"

标签: php html css internet-explorer-8


【解决方案1】:

我在这里猜测是因为我不想查看您的所有代码,但我想当用户关注 input 时,您正在用 &lt;input type="password" /&gt; 替换 &lt;input type="text" /&gt;。我不认为这是最好的跨浏览器解决方案。

如果您想支持旧版浏览器,则需要使用 javascript 解决方案,因为 HTML5 placeholder 值不适用于所有浏览器。

一个好的解决方案是使用位于input 下方的&lt;label&gt; 标签,而不是伪造它。一个很好的例子见:http://blog.stannard.net.au/2011/01/07/creating-a-form-with-labels-inside-text-fields-using-jquery/

此解决方案的优势包括跨浏览器兼容性、可访问性和语义标记。

【讨论】:

    猜你喜欢
    • 2013-04-24
    • 2015-01-30
    • 1970-01-01
    • 1970-01-01
    • 2013-03-25
    • 2012-08-09
    • 1970-01-01
    • 1970-01-01
    • 2013-05-24
    相关资源
    最近更新 更多