EmbeddedXopus
Description
When you are running SDL LiveContent Create embedded in an <iframe>, odds are that you would like to communicate with the SDL LiveContent Create running in the frame, telling it what document to load for example. When you include the xopus/embedded.js a new global object will be available: EmbeddedXopus. It distributes the Editor object from your SDL LiveContent Create frames available in their parent frames.
Instead of polling for the frame.contentWindow.Editor property to appear, you can add an event listener for that to EmbeddedXopus. Once the API is available, your function will be called, and the first argument is an object containing the Editor object (and others).
The following example shows how SDL LiveContent Create can be hidden until it has loaded a document:
function openDocument(uri) {
EmbeddedXopus.addListener(apiAvailable, "document");
}
function apiAvailable(api, name) {
api.Editor.addEventListener("load", function () {
document.getElementById(name).style.display = 'block';
});
}
<script src="/xopus/embedded.js"></script>
<dl>
<dt>John's documents</dt>
<dd><iframe name="overview" src="/overview.html"></iframe></dd>
<dt>Document</dt>
<dd><iframe id="document" name="document" src="/xopus/xopus.html"></iframe></dd>
</dl>
The second argument for addListener() and removeListener() is optional, but can be used to work with multiple iframes.
Note: Cross-site communication isn't possible. This functionality is only available when the pages are hosted on the same host.
Note: Internet Explorer doesn't properly supportiframe.setAttribute("name", "value"), so when creating an iframe using script use document.createElement("<iframe name='name'>") instead, but just for Internet Explorer.