1.Type=radio的选中问题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
123<input type="radio" value="1" onchange="fnRadio.GetRadioValue('fname')" onClick="this.blur();" name="fname" />
453<input type="radio" value="0" onchange="fnRadio.GetRadioValue('fname')" onClick="this.blur();" name="fname" />
<script>
var fnRadio = {
IsNullOrEmpty:function(str){
if(typeof(str)=="undefined") return true;
if(str==null) return true;
if(str=="") return true;
return false;
},
GetRadioValue:function(radioName)
{
var radios = document.getElementsByName(radioName);
for(var i = 0 ; i< radios.length; i++)
{
var radio = radios.item(i);
if(radio.checked)
{
if(fnRadio.IsNullOrEmpty(radio.value)) return undefined;
console.log("当前选中的值:",radio.value)
return radio.value;
}
}
return undefined;
}
}
</script>
</body>
</html>
Onclick = this.blur()为了选择后立即触发
2.IE不兼容获取滚动条的高度
3.IE不兼容Jquery
4.getElementsByTagName 不支持
通过getElementByClassName来处理
5.IE5不兼容rgba ,解决如下:
background-color:rgba(0,0,0,0.4);
-ms-filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#7F000000,endColorstr=#7F000000);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#7F000000,endColorstr=#7F000000);
6.IE5不支持事件监听,例如addEventlistener
7.由于不兼容jq所以好多日历插件都用不了,建议使用calendar
插件代码地址:
https://download.csdn.net/download/baidu_41604826/15702656
8.IE5不兼容maxlength,
添加onKeyDown=“if(this.value.length >= 160){ return false }”
但是onKeyDown有一个问题就是字数上限后就无法删除了,所以最佳为如下方式:
<textarea name="" id="" cols="30" rows="10" maxlength="20" onpropertychange="if(this.value.length >= 120) {this.value=this.value.substr(0,20) }"></textarea>
9.非兼容问题——iframe多层嵌套的时候的返回问题:
window.parent.location.href=“返回的地址”
同时是附带刷新的
10:window.attachEvent在非IE浏览器无法使用,所以使用时需要做判断
例如:
if(window.attachEvent){
window.attachEvent("onload", foo);
}else if(window.addEventListener){
window.addEventListener("onload", foo, false);
}
11.非用户自主事件使用:window.open() 打开新窗口再非IE浏览器会被拦截问题
例如:请求数据返回成功之后打开一个新窗口,在IE是正常的,但是火狐、谷歌提示被拦截。
解决办法:创建一个新标签,执行点击事件,打开新窗口
if("是IE浏览器"){
window.open("网页地址")
}else {
var $a = document.createElement('a');
var ev = document.createEvent('CustomEvent');
ev.initCustomEvent('click',false,false)
$a.addEventListener('click', function(val){
window.open("网页地址")
}, false);
$a.dispatchEvent(ev);
}