我们在Websphere Portal Server上部署了几个portlet。在css文件中,我们包含了img标记的行为属性。
img {
position:relative;
border:none;
outline:none;
behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')", this.src = "transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("', '').replace('")', ''), this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')", this.runtimeStyle.backgroundImage = "none")), this.pngSet=true) );
}
我们已经发现这个行为标记导致多个HTTP请求。在其中一个Portlet JSP中,我们包含了一个样式类,如下所示
<link rel="stylesheet" type="text/css" title="Style"
href=''<%=request.getContextPath()+"/theme/stylesheet.css" %>'>
只有当我们有request.getContextPath()时才会出现问题。如果我用实际的上下文根替换它,它就不会给出问题。有人可以让我知道为什么行为属性会导致问题吗?
答案 0 :(得分:1)
雅虎!有一篇文章标题为加速网站的最佳实践。有一点需要避免的是CSS中的表达式,因为只需移动鼠标或滚动页面,它们的评估频率比预期的要高一些。
这篇文章可以在这里阅读并查找标题避免CSS表达式: