The insdljs package is used to add document level JavaScript. The package requires to specify the output driver. \begin{lstlisting} \usepackage[pdftex]{insdljs} \end{lstlisting} The JavaScript-code to add is placed in an \textit{insDLJS\/} environment. The optional argument and the first required argument must be \LaTeX{} identifiers (use a string containing characters only, no numbers). The second required argument is a comment \begin{lstlisting} \begin{insDLJS}[exaaaa]{exaaaa}{Document Level JavaScript} // ... Place Java source code here ... \end{insDLJS} \end{lstlisting} The identifier is used to build a file name (``exaaaa.djs'') to temporarily store the packed JavaScript code. The \textit{OpenAction\{\}\/} macro specifies a function which is executed when the document is opened. \begin{lstlisting} \OpenAction{/S /JavaScript /JS (myFirstJavaScriptFunction();)} \end{lstlisting} The JavaScript-code is enclosed in brackets. The example code contains a function invokation. The function may be invoked multiple times (each time one navigates to page 1). We use a variable as a flag indicating whether the function is run for the first time or not. \lstinputlisting{../examples/ex0006.tex} A message box is shown when the document is opened. In the german version the character \"{o} is malformed to ``\"{}o'' because the inputenc package replaces german umlauts (and other characters) by the corresponding \LaTeX{} code sequence. There are two ways to solve the problem: \begin{itemize} \item Remove the inputenc package and convert german umlauts to their \LaTeX{} code sequence manually (shown in the listing below at the end of this section) or \item use JavaScript-Unicode notation for umlauts in JavaScript instead of typing the umlauts directly (shown in section~\vref{sec:fde0020}). \end{itemize} \begin{lstlisting} \usepackage[latin1]{inputenc} \end{lstlisting} from our source. \lstinputlisting{../examples/ex0007.tex}