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

JavaScript DHTML 函數的範例

Procedure使用 JavaScript DHTML 函數範例

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

    portal-server-URL /rewriter/JavaScript/functions/dhtml/dhtml.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>
Testing JavaScript DHTML Functions
<br>
<br>
<script>
<!--
document.write(\q<a href="/index.html">write</a><BR>\q)
document.writeln(\q<a href="index.html">writeln</a><BR>\q)
document.write("http://abc.sesta.com/index.html<BR>")
document.writeln("http://abc.sesta.com/index.html<BR>")
//-->
</SCRIPT>
</head>
<body BGCOLOR=white>
<br><br>
Testing document.write and document.writeln
</body>
</html>

規則

<Function type="DHTML" name=" document.write" paramPatterns="y"/>
<Function type="DHTML" name=" document.writeln" paramPatterns="y"/>

重新寫入後的 HTML 網頁

<html>
<head>
Testing JavaScript DHTML Functions
<br>
<br>
<script>
<!--
document.write(\q<a href="gateway-URL
/portal-server-URL/index.html">write</a><BR>\q)

// 第一個規則指出 DHTML JavaScript 函數 document.write 的第一個參數需要重新寫入。Rewriter 會將第一個參數識別為一個簡單的 HTML 陳述式。在 default_gateway_ruleset 中的 HTML 規則部分具有規則 <Attribute name="href" />,此規則指出此陳述式需重新寫入。

document.writeln(\q<a href="gateway-URL
/portal-server-URL/rewriter/JavaScript/functions/dhtml/index.html">writeln</a><BR>\q)

// 第二個規則指出 DHTML JavaScript 函數 document.writeln 的第一個參數需要重新寫入。Rewriter 會將第一個參數識別為一個簡單的 HTML 陳述式。在 default_gateway_ruleset 中的 HTML 規則部分具有規則 <Attribute name="href" />,此規則指出此陳述式需重新寫入。

document.write("http://abc.sesta.com/index.html<BR>")
document.writeln("http://abc.sesta.com/index.html<BR>")

// 雖然 DHTML 規則識別出函數 document.writedocument.writeln,但上述陳述式並未重新寫入。這是因為這個情況下的第一個參數並非簡單 HTML。其可能是任何字串而 Rewriter 不知如何將之重新寫入。

//-->
</SCRIPT>
</head>
<body BGCOLOR=white>
<br><br>
Testing document.write and document.writeln
</body>
</html>