经过研究找到了答案,需要使用js调用style对象的removeExpression()方法才可去除。
下面是方法的说明:
语法
bSuccess = object .removeExpression( sPropertyName )
参数
sPropertyName Required. String that specifies the name of the property from which to remove an expression.返回值
Returns one of the following possible values:
true The expression was successfully removed. false The expression was not removed.下面给出一个实用例子:利用样式限制图片最大宽度,通过一个按钮切换实际大小与缩放大小。
CSS类,作用:限制图片的最大宽度,超出指定宽度等比缩小。
Css代码
.wrap { border:none; max-width:730px; height:auto; width:expression(this.width>730?"730px":true);/*ie6补丁*/ }
图片
Html代码
切换按钮
Html代码
[原始大小]
js代码(需要jQuery)
Java代码
function showOrigin(){ $('#chart_img').toggleClass("chart"); if($('#chart_img').attr("class")){ $('#imgctr').text("[原始大小]"); }else{ $('#imgctr').text("[缩放大小]"); $('#chart_img')[0].style.removeExpression('width'); /*ie6补丁*/ } }
这个事例只有在IE6中才能体现removeExpression()的作用,ie7以上是不需要的。
查看更多关于去掉CSS中的表达式Expression_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did105916