javascript css styleFloat和cssFloat
更新时间:2010年03月15日 11:52:02 作者:
在写js操作css的过程中发现float属性在IE和firefox下对应的js脚本是不一样的,IE下对应得是 styleFloat,firefox,chorme,safari下对应的是cssFloat,可用in运算符去检测style是否包含此属性。
下面是兼容性代码
LTFunction.setFloatStyle=function(obj,style)
{
var sty=obj.style;
if('cssFloat' in sty){
obj.style.cssFloat=style;
}else if('styleFloat' in sty){
obj.style.styleFloat=style;
}else{
throw 'set float style:'+style+'error.';
}
}
复制代码 代码如下:
LTFunction.setFloatStyle=function(obj,style)
{
var sty=obj.style;
if('cssFloat' in sty){
obj.style.cssFloat=style;
}else if('styleFloat' in sty){
obj.style.styleFloat=style;
}else{
throw 'set float style:'+style+'error.';
}
}
您可能感兴趣的文章:
- javascript css float属性的特殊写法
- css 跨浏览器实现float:center
- CSS中Float(浮动)相关技巧文章
- javascript下操作css的float属性的特殊写法
- css position: absolute、relative详解
- CSS定位中Positoin、absolute、Relative的一些研究
- relative absolute无法冲破的等级问题解决
- Div CSS absolute与relative的区别小结
- position:relative/absolute无法冲破的等级
- 解决rs.absolutepage=-1的问题
- 详细分析css float 属性以及position:absolute 的区别
相关文章
在JavaScript中使用严格模式(Strict Mode)
这篇文章主要介绍了在JavaScript中使用严格模式(Strict Mode),除了正常运行模式,ECMAscript 5添加了第二种运行模式:"严格模式"(strict mode)。顾名思义,这种模式使得Javascript在更严格的条件下运行。,需要的朋友可以参考下2019-06-06
uniapp使用uni.chooseLocation()打开地图选择位置详解
这篇文章主要给大家介绍了关于uniapp使用uni.chooseLocation()打开地图选择位置的相关资料,因为最近在项目中遇到一个要用户授权位置且可以用户自己选择位置的功能,需要的朋友可以参考下2023-06-06


最新评论