可从以下位置访问本示例:
portal-server-URL /rewriter/JavaScript/functions/djs/djs.html
确保在网关服务的“域和子域的代理”列表中定义了 abc.sesta.com。
如果没有定义该项,则假定采用直接连接,不会在其前面加网关 URL。
将本示例中指定的规则(如果尚不存在)添加到“JavaScript 源重写规则”一节的 default_gateway_ruleset 中。在 Portal Server 管理控制台中,编辑 Portal Server 配置下的重写器服务中的 default_gateway_ruleset。
重新启动网关:
./psadmin start-sra-instance –u amadmin – f <password file> –N <profile name>– t <gateway> |
<html> Test for JavaScript DJS Functions <br> <script> menu.addItem(new NavBarMenuItem("All Available Information","JavaScript:top.location=\qhttp://abc.sesta.com\q")); //menu.addItem(new NavBarMenuItem("All Available Information","http://abc.sesta.com")); </script> </html>
<Function type="DJS" name="NavBarMenuItem" paramPatterns=",y"/> <Variable type="URL" name="top.location"/>
<html> Testing JavaScript DJS Functions <br> <script> menu.addItem(new NavBarMenuItem ("All Available Information","javaScript:top.location= \qgateway-URL/http://abc.sesta.com\q"));
// abc.sesta.com 是网关服务的“域和子域的代理”列表中的一项。因此重写器需要重写这个 URL。但由于是一个绝对 URL,所以不需要在其前面加 Portal Server URL。此 DJS 规则规定需要重写 DJS 函数 NavBarMenuItem 的第二个参数。但第二个参数还是一个 JavaScript 变量。此时还需要第二项规则来重写该变量的值。第二项规则指定需要重写 JavaScript 变量 top.location 的值。由于满足上述所有条件,所以会重写此 URL。
//menu.addItem(new NavBarMenuItem("All Available Information","http://abc.sesta.com"));
// 虽然此 DJS 规则指定需要重写函数 NavBarMenuItem 的第二个参数,但在本语句中不会发生这种情况。这是因为重写器不会将第二个参数识别为简单 HTML。
</script> </html>