您可自下列路徑存取此範例:
portal-server-URL /rewriter/JavaScript/variables/system/system.html
將此範例中指定的規則新增 (若尚不存在) 至 [重新寫入 JavaScript 來源的規則] 部分的 default_gateway_ruleset 中。
在 Portal Server 管理主控台的 Portal Server 配置下,編輯 Rewriter 服務中的 default_gateway_ruleset。
重新啟動閘道:
./psadmin start-sra-instance –u amadmin – f <password file> –N <profile name>– t <gateway> |
<html>
<head>
<title>JavaScript SYSTEM Variables Test Page</title>
</head>
<body>
<script LANGUAGE="Javascript">
<!--
//SYSTEM Var
alert(window.location.pathname);
//document.write
("<A HREF="+window.location.pathname+">SYSTEM</A><P>")
//-->
</SCRIPT>
Testing JavaScript SYSTEM Variables
<br>
This page displays the path where
the current page is located when loaded.
</body>
</html>
<Variable name="window.location.pathname" type="SYSTEM"/>
<html> <head> <title>JavaScript SYSTEM Variables Test Page</title> </head> <body> <SCRIPT> convertsystem function definition... </SCRIPT> <script LANGUAGE="Javascript"> <!-- //SYSTEM Var alert(psSRAPRewriter_convert_system (window.location, window.location.pathname, "window.location"));
// Rewriter 會將 window.location.pathname 識別為 JavaScript SYSTEM 變數。此變數的值無法於伺服器端判定。因此 Rewriter 會在變數前前置 psSRAPRewriter_convert_pathname 函數。此包裝函數可於用戶端判定此變數的值,然後依需要重新寫入。
//--> </SCRIPT> Testing JavaScript SYSTEM Variables <br> This page displays the path where the current page is located when loaded. </body> </html>