Any section or subsection of PubChem summary or record pages (compounds, elements, substances, bioassays) as well as periodic table can be turned into a widget to be embedded into any web page. See widget examples to get a quick idea of the possibilities.
For instance, below is an IUPAC Name section from compound summary page for aspirin (https://pubchem.ncbi.nlm.nih.gov/compound/aspirin#section=IUPAC-Name) embedded into this page as a widget.
To embed a PubChem widget from above example, add the following code to your page at the location where you want the widget to appear:
To find the value for the src attribute for the iframe of a PubChem widget, scroll to the section of interest such as https://pubchem.ncbi.nlm.nih.gov/compound/aspirin#section=IUPAC-Name and then add "&embed=true" at the end of the URL. Thus, you will have https://pubchem.ncbi.nlm.nih.gov/compound/aspirin#section=IUPAC-Name&embed=true.
Note that you can wrap the widget in a container, which can be styled as you like:
As shown in examples above, the iframe has to have the width and the height set inside the style attribute.
It is generally a good idea to set the iframe width parameter to 100%, and if a smaller width is desired, wrap the iframe in a container with a desired width set in the container's style parameter. See the code examples above.
Setting the iframe height to an optimal value can be more difficult. If the content height exceeds the iframe height, a vertical scrollbar appears in the iframe. On the other hand, if the iframe height is set to a high value, there can be a lot of empty space below the content.
If you would like to avoid vertical scrollbars on the widgets, we provide a method to automatically adjust the widget iframe height to that of the content.
To use this method, add scrolling="no" attribute to the iframe and do not set the height on the iframe or the container as shown below:
In addition, add the following code (open source iframe resizer) to your page (only once, even if you have multiple pubchem widgets on the page) just before the closing body tag:
Note that some PubChem page sections can be very long, and thus, it is up to you to decide whether a vertical scrollbar is better suitable for your pages.
In some cases, when the page prominently includes record title (such as "Tiformin" it might be desirable to leave out the record title from the widget.
To do so, use the option hide_title=true in the iframe src attribute as shown below:
If the URL provided in the iframe src attribute does not exist in PubChem, the results of what shows up in the iframe might be unpredictable - it could be a 404 page or a search interface depending on what exactly was in the src attribute.
However, if the widget links to a nonexistent section of a valid PubChem record, then the widget will simply display a message saying that the section for that particular record does not exist, see below:
- BioAssay Description
- BioAssay Data Table
- Compound 2D Structure
- Compound 3D Conformer
- Compound Bioactivities Table
- Compound Literature Citations
- Compound Patents
- Substance Bioactivities Table
- Compound Classification
- Compound Related Records
- Periodic Table
- Periodic Table Game
- Element Information Card
- Element History
Note that this list of examples is not exhaustive and that any section or subsection in the table of contents of Compound Summary or BioAssay/Substance Record pages can be embedded as a widget. However, please keep in mind that some sections might be more useful than others as standalone widgets.
National Library of Medicine
8600 Rockville Pike
Bethesda, MD 20894