从IE 到 Chrome:旧工程兼容性改造——document.frames()
运行环境
涉及到ie7,ie11,和chrome63,chrome43
用法差别
在ie7中,document.frames的使用是
document.frames('frameName')
返回值是对应frame的window对象。但是如果参数不是iframe的name属性值,而是id属性的值,返回同样是对应iframe的window对象。
如:
htmlDemo
<!DOCTYPE html>
<html>
<body>
<iframe name="test1">
</iframe>
<iframe id="test3">
</iframe>
<script>
window.onload = function () {
var isIE = ……
if (isIE) {
console.log(document.frames('test1'), document.frames('test3') ) // ie7
} else {
console.log(window.frames['test1'], window.frames['test3'] )
}
}
</script></body>
</html>