Sun Java System Portal Server Secure Remote Access 7.2 管理指南

JavaScript SYSTEM 變數的範例

Procedure使用 JavaScript SYSTEM 變數範例

  1. 您可自下列路徑存取此範例:

    portal-server-URL /rewriter/JavaScript/variables/system/system.html

  2. 將此範例中指定的規則新增 (若尚不存在) 至 [重新寫入 JavaScript 來源的規則] 部分的 default_gateway_ruleset 中。

  3. 在 Portal Server 管理主控台的 Portal Server 配置下,編輯 Rewriter 服務中的 default_gateway_ruleset

  4. 重新啟動閘道:


    ./psadmin start-sra-instance –u amadmin – f  <password file> –N <profile name>– t  <gateway>
    

重新寫入前的 HTML 網頁

<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

<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>