Jmol PHP

From Jmol
Jump to navigation Jump to search

Jmol.php: easy Jmol insertion into a web page

You can insert a Jmol applet into a web page with nothing more than a simple <script> or <a> tag. You don't have to install any Jmol files in your computer or web server. You don't even need a file with the 3D model; it will be automatically obtained from an appropriate web server.

Note that this way of using Jmol is easily compatible with any environment where you do not control the full source code, like forums, blogs, wikis, content management systems, e-learning environments... In fact, you can email the address and the recipient will see the Jmol applet by clicking on the received link.

If you invoke a PDB 4-character id, the model will be retrieved from the wwPDB (RCSB). If you invoke a chemical name, commercial name, SMILES string, InChI key, or CAS registry number, the model will be retrieved from the CACTVS server (NIH).

General syntax

You must link to this page

which does all the magic (a courtesy of Bob Hanson and the servers at St. Olaf College). After that URL, text must be added to specify the molecule and some options. Such a text must follow the conventions for URIs, that is:

  • first goes a ? sign
  • then, pairs of name=value
  • if more than one name/value pair, they must be separated by an ampersand, & sign

Common options

One option among 1 to 3 is needed to define the molecule or model that will be displayed. The others are elective and affect the style of the applet or the model inside it.

  1. source=... the file source of a model, starting with http://
  2. model=... a name of a chemical, or SMILES string, InChI key, or CAS registry number.
  3. pdbid=... the 4-character ID of the model at the Protein Data Bank (RCSB, wwPDB).
  • inline a return JavaScript to create the applet in the current page.
  • link=... a text to make the hyperlink to a popup window.
  • script=... a Jmol script (should be simple).
  • scriptvar=... a previously defined JavaScript variable name or function (not the script itself; only with inline).
  • width=... the width of the applet, either in pixels or in percent.
  • height=... the height of the applet, either in pixels or in percent.
  • caption=... a caption (only for the anchor type, not with inline and not with link).
  • title=... a title (not with inline).

Anchor format

Creates a link to a new page with the model in Jmol. (You can specify the target in the <a> tag, so that the page either replaces the current one or opens in a new window or tab in the browser)

Popup format

Creates a link to pop up a new window of a specified size, containing the Jmol applet with the model.

Inline format

Displays the Jmol applet inserted in the current page.


<script type="text/javascript"