Chapter 6: Definition Reference

define javascript

A javascript definition is used to define a javascript transformer, which adds javascript that you supply to HTML responses.

Syntax

define javascript transformer_id javascript-statement[javascript-statement]

end

where:

transformer_id—A user-defined identifier for a transformer definition block. Used to invoke the transformer using the transform action in a define action definition block.

A javascript-statementhas the following syntax:

javascript-statement ::=section-type replacement section-type ::=prolog onload epilog

replacement ::= << endmarker newline lines-of-text newline endmarker

This allows you to specify a block of javascript to be inserted at the beginning of the HTML page (prolog), to be inserted at the end of the HMTL page (epilog), and to be executed when parsing is complete and the page is loaded (onload). Each of the section types is optional.

Layer and Transaction Notes

Applies to proxy transactions.

Example

The following is an example of a javascript transformer that adds a message to the top of each Web page, used as part of a simple content filtering application:

define javascript js_transformer onload <<EOS

var msg = "This site is restricted. Your access has been logged."; var p = document.createElement("p"); p.appendChild(document.createTextNode(msg)); document.body.insertBefore(p, document.body.firstChild);

EOS end

define action js_action transform js_transformer

end

<proxy>

category=restricted action.js_action(yes)

The VPM uses javascript transformers to implement popup ad blocking.

255

Page 255
Image 255
Blue Coat Systems Proxy SG manual Define javascript