javascript
The <javascript/> element points to a javascript file that is executed when Xopus activates an Xopus Canvas. The script is executed after the configuration is loaded but before any associated files are loaded. The script has access to the Xopus API.
Example
<config version="1.0" xmlns="http://www.xopus.com/xmlns/config">
<import src="config.xml"/>
<javascript src="js/blockdragger.js"/>
<pipeline xml="xml/doc.xml" xsd="xsd/schema.xsd">
<view id="defaultView" default="true">
<transform xsl="xsl/presentation.xsl" />
</view>
<view id="Other View">
<treeTransform/>
</view>
</pipeline>
</config>
Javascript loaded using a <script> element in the html can also access the Xopus API. However, the Xopus API may not be fully initialized when such a script is executed. Xopus can not signal such a script that is ready to be accessed. The only way to be sure is to detect if the Editor object is intialized yet.
Example
// Demo of polling technique needed to wait
// for the Xopus API when the <javascript/>
// element is NOT used.
function waitForXopus()
{
if (typeof Editor == "undefined")
setTimeout(waitForXopus, 250);
else
useXopusAPI();
}
function useXopusAPI()
{
...
}
Elements and Attributes
Parent Elements
| Element | Description |
|---|---|
| config |
The
|
Child Elements
None
Attributes
| Attribute | Use | Description |
|---|---|---|
| src | Required |
The |
- Support /
- Documentation /
- Developer Guide /
- Reference /
- Xopus Local Configuration /
- Elements /
- javascript
Related Topics
| Title | Description |
|---|---|
| Upgrade from Xopus 2 to 3 |
Xopus 3 is not backward compatible with Xopus 2. So in order to upgrade to Xopus 3, the Xopus integration needs to be upgraded as well. This document explains the steps you need to take to upgrade your Xopus 2 integration. |
| Xopus API |
The Xopus API allows integrators to customize Xopus. This ranges from configuring Xopus to save xml to building custom user interfaces on top of Xopus. |
| src |
The |
| Script Files |
The Xopus API can be accessed in multiple ways. |