Annotation API

This is intended to be used by webmasters/bloggers wishing to add pop-up annotation to their web pages. If you are interested in adding this functionality to your browser instead, you should look at the annotation bookmarklet.

Quick Start

Add the following before </body>, where you'd usually put Google analytics and such

<script src="//" charset="UTF-8"></script>

Send a quick note indicating URL of your website.

That's it. It should work with all the assumed defaults.

Now some more details

The script can be loaded anywhere, but to avoid delaying loading of the main content, it either needs to be done asynchronously or at the bottom of the body as suggested above.

Te call to the annotate() has to be done after the script is loaded and the DOM (at least the part that we want to annotate) is ready. Again, placing the call at the bottom of the page, as suggested in the previous section, will work well.

The main call is mandarinspot.annotate(selector, options). Both arguments are optional.

selector can either be If omitted, document.body is used.

options is an object with two optional members:

These two calls can be used to switch pop-ups on and off respectively


If you want pop-ups initially be inactive, you can call it like this:

<script>mandarinspot.annotate('#chinesetext', {phonetic: 'pinyin', show: false});</script>

If something is unclear or if you think there is something else needs to be implemented, changed or fixed, please ask.


This doesn't work in IE7 and earlier and all versions of Opera before 12.00 due to cross origin requests not being implemented properly in these browsers. So if you choose to have pop-ups on/off switchable, you probably have to hide the switch UI element in case it can't work.

To detect whether API is supported in the current browser you can call mandarinspot.supported(), which will return true or false based on best guess after detecting some browser features.


All Chinese text found on the page is sent to the MandarinSpot server for segmentation and retrieval of the dictionary definitions. This information is not stored in any form on the server, but the transmission itself is done without encryption at the moment, which makes it possible for the data to be observed by a third party while in transit.

Home - Privacy Policy - API - Mobile Version