EmbedCode[obj]
generates the code necessary to embed the object obj on a web page.

EmbedCode[obj,"dest"]
generates code for an external environment or language of type .

EmbedCode[obj,"dest",dir]
saves the generated code as files in the directory dir.

EmbedCode[obj,"dest",loc]
saves the generated code as a file archive in the file location loc.

Details and OptionsDetails and Options

  • In EmbedCode[obj], the object obj can be a CloudObject.
  • EmbedCode[obj] returns a string that can be inserted into the HTML of a web page to embed obj on the page.
  • In EmbedCode[obj,"dest"], the object obj can be a function with head APIFunction or FormFunction.
  • EmbedCode[obj,] also allows ExternalBundle objects representing a bundle of named resources.
  • Possible destinations for EmbedCode are given by the value of $EmbedCodeEnvironments.
  • Destinations relevant to the web include:
  • "WebPage"URL for complete web page
    "IFrame"embed code for an embeddable iframe
    "HTML"standalone HTML code to be embedded on a page
    {"dest",framework}use the specified framework for the code generated
  • Possible frameworks for interactive web content include:
  • "CloudCDF"CloudCDF with interactivity purely powered by the cloud
    "CloudCDFAllowingPlugin"CloudCDF with autodetection of local CDF plugin
    "CDFPlugin"cloud-hosted CDF for CDF plugin
  • General web frameworks include: , . None uses no additional frameworks.
  • Destinations relevant to languages include: "Java", "Python", "JavaScript", "C#", etc.
  • In typical cases of external programming languages, EmbedCode returns an EmbeddingObject containing an Association giving a variety of elements necessary for the embedding.
  • Typical options for EmbedCode include:
  • ExternalOptions<||>options specific to each environment or language
    ExternalFunctionNameAutomaticname to use for generated external function
    ExternalTypeSignatureAutomaticrules specifying mappings to external types
    ImageSizeAutomaticsize of embedded object in pixels
    MethodAutomaticembedding method to use
    PermissionsAutomaticpermissions to set for the cloud object
  • With the default setting Permissions->Automatic, EmbedCode[obj] will preserve the permissions for a cloud object obj and will use permissions given by $Permissions if a new cloud object is created.
  • With an explicit setting for Permissions, EmbedCode[obj] will effectively use SetOptions to change permissions of a cloud object obj.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Create embed code for embedding on the web:

In[1]:=
Click for copyable input
Out[1]=

Specify the size of embedding region:

In[2]:=
Click for copyable input
Out[2]=

Create code for calling an API from Java:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2014
(10.0)