如何让ie9以下版本的ie浏览器支持document.defaultView方法 RT~~~如何让ie9以下版本的ie浏览器支持document.defaultView方法,或者其它可用的方法也行。下载了一个js库,里面的document.defalutView在ie上不支持(操作系统win XP,没法装ie9)。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你要实现什么功能?defaultView这个属性还真没用过。。获取默认样式还是干嘛? defaultView是FF、chrome获取样式的方法,IE9可能支持了,IE9以下的应该还不支持针对这个问题呢,用currentStyle来解决吧,具体代码自己组织一下哈,,就是判断有defaultView属性就用defaultView,没有就用currentStyle方法 defaultView是FF、chrome获取样式的方法,笔误。。无非就是获取样式的兼容处理,一般还会在后面调用getComputedStyle方法,所以最好仔细看看再组织自己的兼容低吗。 我也碰到了这个问题,上楼说得对,defaultView后面有调用ComputedStyle方法,请问针对这种情况如何解决?尝试用CurrentStyle也不行。求解中。 if(!document.defaultView){ document.defaultView = {}; document.defaultView.getComputedStyle = function(obj){ return obj.currentStyle; }}试试看。。手边只有FF跟IE9,没办法测试低版本IE。不过这里有个问题,FF下通过getComputeStyle获取出来的是具体的数值,比如宽度会得到100px这样,但是IE下currentStyle取到的可能是auto。if(!document.defaultView){ document.defaultView = {}; document.defaultView.getComputedStyle = function(obj){ return obj.currentStyle; }}var lg = document.getElementById('lg')console.log(document.defaultView.getComputedStyle(lg).width)以上代码百度首页跑出来FF下是720px,IE9下是auto。。 如果你没有在css样式里明确写上{height: 729px},那么获取的就是默认值或者null这个时候你就得用clientHeight,scrollHeight,offsetHeight来取得你要的值才行 jquery取指定form中的指定input 菜鸟求教JS问题 求助!! JS如何获取元素属性 如何用js控制让指定的图层显示在最上层,我将z-index的值设成最大也没用 缺少对象…… javascript技术问题,请高手指点 一个菜鸟问题 关于window.open,谢谢 我的浏览器如何才能修改 jQuery slideDown()方法问题 ajax接收后台传来的图片应该如何接收
defaultView是FF、chrome获取样式的方法,笔误。。无非就是获取样式的兼容处理,一般还会在后面调用getComputedStyle方法,所以最好仔细看看再组织自己的兼容低吗。
请问针对这种情况如何解决?尝试用CurrentStyle也不行。求解中。
if(!document.defaultView){
document.defaultView = {};
document.defaultView.getComputedStyle = function(obj){
return obj.currentStyle;
}
}
试试看。。手边只有FF跟IE9,没办法测试低版本IE。不过这里有个问题,FF下通过getComputeStyle获取出来的是具体的数值,比如宽度会得到100px这样,但是IE下currentStyle取到的可能是auto。if(!document.defaultView){
document.defaultView = {};
document.defaultView.getComputedStyle = function(obj){
return obj.currentStyle;
}
}
var lg = document.getElementById('lg')
console.log(document.defaultView.getComputedStyle(lg).width)
以上代码百度首页跑出来FF下是720px,IE9下是auto。。
如果你没有在css样式里明确写上{height: 729px},那么获取的就是默认值或者null
这个时候你就得用clientHeight,scrollHeight,offsetHeight来取得你要的值才行