`

解决placeholder在IE浏览器不兼容的问题

    博客分类:
  • Java
阅读更多

解决placeholder在IE浏览器不兼容的问题

 

解决方式:加上label标签。(IE显示该标签,其他浏览器不显示。)

 

1.html:

<div class="fl">
	<label id="oldPwdTip">为了您账户安全请修改原始密码</label>
    <input id="oldPwd" class="usertext" type="password" name="userName" placeholder="为了您账户安全请修改原始密码"
    	onkeypress="hideOldPwdTip();" onblur="toggleOldPwdTip(this.value);" />
    <span id="oldPwdTip2"></span>
</div>

 

2.样式:(注意float和absolate)

.fl{ float:left; width:350px; margin-left:8px;}
#oldPwdTip{
	position: absolute;
	color : #ccc;
	margin-top : 6px;
	margin-left : 6px;
}

 

3.IE显示label脚本:

$(function(){
	/* IE浏览器的输入框提示 */
	var platform = navigator.platform;
	var o = navigator.appName ;
	if (o.toString().indexOf("Internet") == -1) {
		document.getElementById("oldPwdTip").style.cssText = "display: none;" ;
		document.getElementById("newPwdTip").style.cssText = "display: none;" ;
		document.getElementById("repeatPwdTip").style.cssText = "display: none;" ;
	}
});

 

4.按下键盘不显示,失去焦点重新显示:

function hideOldPwdTip() {
	document.getElementById("oldPwdTip").style.cssText = "display: none;" ;
}

function toggleOldPwdTip(v) {
	if (!v) {
		var o = navigator.appName ;
    	if (o.toString().indexOf("Internet") != -1) {
			document.getElementById("oldPwdTip").style.cssText = "display: block;" ;
    	}
	}
}

 

Chrome:

 

IE:

 

 

  • 大小: 1.2 KB
  • 大小: 1.3 KB
分享到:
评论

相关推荐

    input中placeholder在Ie上兼容

    使用jQuery快速解决input中placeholder值在ie中无法支持的问题

    IE浏览器支持placeholder

    现在流行html5了都,所有的浏览器都支持placeholder,唯独IE不支持,那么这插件将完美解决IE浏览器不兼容input标签的placeholder属性.

    ie placeholder属性的兼容性问题解决方法

    但是在不支持html5的低版本的浏览器中,placeholder属性是无效的,为了解决这个问题,因此,人为的去实现placeholder属性: 复制代码代码如下: //placeholder功能实现 var placeholder = { add: function (el) { if...

    两种方法基于jQuery实现IE浏览器兼容placeholder效果

    主要介绍了两种方法基于jQuery实现IE浏览器兼容placeholder效果,需要的朋友可以参考下

    jquery.placeholder.js

    JS placeholder插件兼容IE6+浏览器 火狐 谷歌浏览器等

    input框中出现提示文字(兼容ie 火狐 谷歌)

    有好多的提示文字直接写在了input框中,placeholder属性只在高版本的谷歌和火狐中有但是不兼容ie8以下,此附件为input框中出现提示文字(兼容ie 火狐 谷歌)。

    jQuery实现IE输入框完成placeholder标签功能的方法

    则可以在谷歌浏览器等高级浏览器的输入框中实现替换文本的功能,也就是得到如下图所示的对话框: 但是这个属性在WIN7默认的浏览器IE8中无法兼容,更不要说IE6了。也就是说IE里面不支持placeholder这个标签。 不信的...

    输入框灰色提示字体效果

    许多网站在input输入框内都有默认提示字体,html5新增了这一项功能,placeholder,但是不兼容ie浏览器,这个组件可以让你实现兼容ie浏览器

    IBM WebSphere Portal门户开发笔记01

    2、JS屏蔽网页错误不在状态栏显示 236 3、浏览器版本的判断 236 4、编写跨浏览器兼容性的JS代码时,常用到的判断代码 237 5、JS 计算网页内容的宽与高 (浏览器的标准模式与怪异模式) 237 6、JS设置与查看网页的解析...

Global site tag (gtag.js) - Google Analytics