0

我们在 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() 时,问题才会出现。如果我将其替换为实际的上下文根,则不会出现问题。有人可以让我知道为什么该行为属性会导致问题吗?

4

1 回答 1

1

雅虎!有一篇标题为加快网站速度的最佳实践的文章。要避免的一件事是 CSS 中的表达式,因为它们的计算频率比预期的要高,只需移动鼠标或滚动页面即可。

这篇文章可以在这里阅读并寻找标题避免 CSS 表达式

http://developer.yahoo.com/performance/rules.html

于 2010-07-09T04:37:45.050 回答