e="text"> <input type="text"> <input type="text">
可结果却是出现脚本出错,正确的写法应该把CSS样式的定义写进函数内,如下所示:
<style type="text/css"> input {star : expression(onmouseover=function() {this.style.backgroundColor="#FF0000"}, onmouseout=function(){this.style.backgroundColor="#FFFFFF"}) } </style> <input type="text"> <input type="text"> <input type="text">
注意
不是非常需要,一般不建议使用expression,因为expression对浏览器资源要求比较高。
实例:利用css里expression来实现界面对象的批量控制
问题说明: 用过CSS样式我们就知道, 可以定义一批对象的class属性来指定同一个样式来统一界面. 但如何统一同类型的对象的事件? 比如:界面有无数个 <img src="**.jpg"> 如何实现鼠标经过此图片, 图片的src变成是**_over.jpg? 解决方法: 使用css的expression方法, 具体实现要看看.css的写法: /*替换图片CSS*/ #imgScript { /*这里使用对象ID来通配样式, 也可以定义一个css函数*/ star:expression( onmouseover = function() { /*替换图片*/ if(this.hover != null){ this.name = this.src; this.src = this.src.replace('.jpg', '_over.jpg'); this.HasChg = 1; } }, onmouseout = function() { /*还原本来的图片*/ if(this.HasChg != null){ this.src = this.name; this.HasChg = null; } } )
}/*end imgScript*/
http: 上一页 [1] [2] [3] 下一页 |