Chapter I. Basic Integration
Prev | 4. Exchanging Data | Next

## 4. Exchanging Data

At the beginning of this chapter, we already saw how to insert / retrieve content using the JavaScript API. We will now focus upon a few things to consider when using this API to insert / retrieve content.

First of all, we'll learn about special considerations to take care of when using the JavaScript API methods described in the chapter JavaScript API / Java API .

Then we'll have a look at the various sources content may come from.

Finally we'll see how legacy content is handled in edit-on Pro.

### 4.1. JavaScript API Considerations

Some JavaScript API functions are not executed immediately after they are called due to their asynchronous nature. These functions will be queued internally and only be executed when the method pumpEvents() is called manually. The functions that are concerned are the functions described in the chapter JavaScript API / Java API excepted all `get` functions which are always executed immediately.

Example I.15. Using JavaScript functions at run-time

    eop.setImageBase("http://www.internic.com");
    eop.setHTMLDataFromURL("http://www.internic.com");
    eop.pumpEvents();

### Note:

The method `loadEditor()` will execute a call to `pumpEvents()` as soon as the editor has fully loaded. Thus all JavaScript API functions called before calling `loadEditor()` will automatically be called once the editor has been fully initialized.

### 4.2. Content Sources

Content may be inserted into the editor from different sources: by loading a document from a URL or by inserting a string from a form field. You also may want to load complete documents or only document fragments. In addition, you can also insert content per drag & drop or cut & paste. Below you will find a few short examples demonstrating how content can be loaded from one of these various sources.

Example I.16. Loading a content fragment using a form field

Form field the content will be loaded from:

    <form name="myForm">
        <input type="text" name="myContent" value="Some content" />
    </form>

Inserting the content from this form field into an instance of the editor called `eop` :

    eop.insertHTMLData(document.myForm.myContent.value);
    eop.pumpEvents();

Example I.17. Loading content from an URL

    eop.setHTMLDataFromURL("http://www.w3.org");
    eop.pumpEvents();

### 4.3. Handling of Legacy Content

By default edit-on Pro will produce valid content according to the XHTML transitional DTD. However, most content on the web or created with Microsoft Word™ or other office applications will not be valid XHTML.

Thus to assure the editor's interoperability with other applications or legacy data, edit-on Pro will verify the validity of any content inserted and perform a clean-up of the content if it is invalid or not well-formed.

### Note:

The clean-up may be disabled or replaced with a custom clean-up process. For more information, see the chapter The Clean-Up Process .

The editor also allows the validation of documents against specific DTDs. By default, edit-on Pro will validate any content that is loaded against the XHTML transitional DTD. If the inserted data is not valid, it will perform a clean-up of the data and remove any elements and attributes not specified in the DTD that is used.

### Note:

For more information on how to validate documents against custom DTDs, see the chapter Using custom DTDs .

Prev | Up | Next
3. Adjusting the User Interface | Home | Chapter II. Advanced Integration