兼容ie8的placeholder解决方法:
if( !('placeholder' in document.createElement('input')) ){
$('input[placeholder],textarea[placeholder]').each(function(){
var that = $(this),
text= that.attr('placeholder');
if(that.val()===""){
that.val(text).addClass('placeholder');
}
that.focus(function(){
if(that.val()===text){
that.val("").removeClass('placeholder');
}
})
.blur(function(){
if(that.val()===""){
that.val(text).addClass('placeholder');
}
})
.closest('form').submit(function(){
if(that.val() === text){
that.val('');
}
});
});
}
<!-- HTML5 Shim and Respond.js 用来支持IE8上的media queries和HTML5元素 -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="../lib/respond/html5shiv.min.js"></script>
<script src="../lib/respond/respond-1.1.0.min.js"></script>
<script src="../lib/respond/rem.min.js"></script>
<![endif]-->
- 设置属性可以改为readonly,readonly仍旧出现光标闪烁问题
$('input[readonly], textarea[readonly]').attr('UNSELECTABLE', 'on');
//input获取焦点时的样式问题 css
input:focus{
box-shadow: none;
-webkit-box-shadow:none;
}
- 手机上设置input为readonly后,点击仍弹出键盘问题
//可以在input中添加unselectable="on" onfocus="this.blur()"
<input type="text" readonly="readonly" unselectable="on" onfocus="this.blur()"/>
兼容ie8无法重复上传相同文件的问题
var ua = navigator.userAgent;
if(ua.toLowerCase().indexOf("msie") > 0){ //判断ie10
var obj = document.getElementById("guidefile") ;
obj.select();
document.selection.clear();
}