Embed an ACP model in a Web page using an iFrame or no frame

<<back


Overview

Suppose you want to allow users to play your model from a web page on your web site. With Analytica Cloud Player (ACP) you can do this.

The way we have found is the easiest to show an ACP model in your web page is to use a frame, this method is described here: Embed an ACP model in a Web Page.

If for some reason HTML frames are not a viable option, you can use one of the methods described here,

Prerequisite: You must already have an ACP account.

When a new user arrives at your web page with the model embedded, the model will appear and an ACP session credit will be consumed.

If you want to display the model without the banner section of the ACP web page, you can find out how to do it here.

Example 1 - Using an IFrame (Inline Frame)

An inline frame is just an HTML document embedded inside another HTML document on a website.

Step 1: Create a Web page.

  • First, create a web page that we can start with. Here is one that just contains a title, 'Look at My Model'.
<html>
<head>
    <title>Look at My Model</title>
</head>
<body>
<h1>Look at My Model</h1>
</body>
</html>

This is what this web page initially displays:

ACP in a web page 05 - Look at my model.png

Step 2: Create the Link.

Currently, you can use ACP’s Email Invite functionality to create the link which will play your model.

  1. Sign into your ACP account
  2. Ensure the model you want to play in your web page is in the Model folder of ACP - it will need to remain there as long as it is embedded in your web page (deleting it would cause an error message for visitors to your web page that the model can't be found).
  3. Use the radio button to select your model.
    ACP inn a web page 01 - model folder.png
  4. Then click the Email Invite button. This starts the email invite creation process and exposes some more UI including the text of the email invite.
  5. Copy the link from this email invite.
    ACP inn a web page 02 - email invite.png
  6. After you copy the link, you press the Cancel button since we aren’t sending the invite to anyone.

Step 3: Insert the code for an Iframe.

  • Now Insert the code for an Iframe with the link to your model in it -
  • I will set the iframe to be 600 pixels wide by 400 pixels high...
  • Paste the link for your model into the "src"attribute, and the code for your web page would look like this:
<html>
<head>
    <title>Look at My Model</title>
</head>
<body>
<h1>Look at My Model</h1>
    <iframe width="600" height="400" src="https://www.analyticacloud.com/acp/ClientAs3/AcpFlex.aspx?inviteId=30&inviteCode=905163&subName=fredbrunt%40gmail%2Ecom"></iframe>
</body>
</html>
  • Now you can save the web page and load the page into a browser and it will display the model in the iframe like this:
ACP in a web page 03 - iframe.png

Example 3 – No Frames – JavaScript

It’s not uncommon to find out that frames are not a viable option; for example because you are using an existing framework that doesn’t support frames, or would require a lot work. Here’s another approach which may work for you.

Step 1 - Start with Your HTML Page

This approach should work with any HTML page you want to use. You just tweak the existing page by adding a javascript include and some code to the <head> and then paste a block of javascript code into the <body>.

Step 2 - <Head>s up

Let’s start with the <Head> section of your HTML page. Usually ACP is loaded using a popular javascript library called swfObject.js. I’m not going to go into the technical reasons for doing this, but just google “swfObject.js” and you’ll find plenty.

To get started we need a web page, so I’m going to start the same as with the iframe - a blank web page that just contains a title, 'Look at My Model'. Here’s the HTML page we are going to start with:

<html>
<head>
    <title>Look at My Model</title>
</head>
<body>
<h1>Look at My Model</h1>
</body>
</html>

This is what this web page initially displays:

ACP in a web page 05 - Look at my model.png

Step 3 - Insert the Source code for the ACP model

So now we are going to add ACP to this page and have it play a model below the title. Similar to Examples 1 and 2, we will start by creating a link that will open your model using ACP’s Email Invite feature.

  • Sign into your ACP account
  • Ensure the model you want to play in your web page is in the Model folder of ACP - it will need to remain there as long as it is embedded in your web page (deleting it would cause an error message for visitors to your web page that the model can't be found).
  • Use the radio button to select your model. Here we'll use the 'car cost in a web page' model
    ACP in web page 04 select car cost.png
  • Then click the [Email Invite] button. This starts the email invite creation process and exposes some more UI including the text of the email invite.
  • Copy the link from this email invite.
    ACP in a web page 5 copy car cost link.png
  • After you copy the link, you press the [Cancel] button since we aren’t sending the invite to anyone.
  • Go to FireFox, paste this link into the address bar and press enter. This should load your model into the browser.
  • Click on the address bar (to ensure focus is on the browser window and not the embedded flash player).
ACP in a web page 6 - Address bar car cost.png
  • What we are after is the source code, so Press Ctrl+U (View source).
  • Now the source code we need is shown. You may need to scroll down a little to the end of the </head>, then copy the block of text shown below:
ACP in a web page 7 copy js code.png
  • Now paste this source code into the <head> of our 'Look at my Model' web page. So far this is how the page looks.
<html><br/>
<head>
<title>Look at My Model</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
    // For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection.
    var swfVersionStr = "11.1.0";
    // To use express install, set to playerProductInstall.swf, otherwise the empty string.
    var xiSwfUrlStr = "playerProductInstall.swf";
    var flashvars = {};
    flashvars.inviteId = '6';
    flashvars.inviteCode = '220947';
    flashvars.subName = 'acp demos';
    var params = {};
    params.quality = "high";
    params.bgcolor = "#ffffff";
    params.allowscriptaccess = "sameDomain";
    params.allowfullscreen = "true";
    params.wmode = "transparent";
    var attributes = {};
    attributes.id = "AcpAs3";
    attributes.name = "AcpAs3";
    attributes.align = "left";
    swfobject.embedSWF(
        "AcpAs3.swf", "flashContent", 
        "100%", "100%", 
        swfVersionStr, xiSwfUrlStr, 
        flashvars, params, attributes);
    // JavaScript enabled so display the flashContent div in case it is not replaced with a swf object.
    swfobject.createCSS("#flashContent", "display:block;text-align:left;");
</script>  
<head>

<body>
<h1>Look at My Model</h1>
</body>
</html>
  • Next, go back to the source code and scroll down to the <body> and copy this block of code - including the <div></div> tags.:
ACP in a web page 8 copy js code.png
  • Paste this code into the <body> as shown below in red; so the web page code looks like this:
<html>
<head>
    <title>Look at My Model</title>
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript">
        // For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection.
        var swfVersionStr = "11.1.0";
        // To use express install, set to playerProductInstall.swf, otherwise the empty string.
        var xiSwfUrlStr = "playerProductInstall.swf";
        var flashvars = {};
        flashvars.inviteId = '6';
        flashvars.inviteCode = '220947';
        flashvars.subName = 'acp demos';
        var params = {};
        params.quality = "high";
        params.bgcolor = "#ffffff";
        params.allowscriptaccess = "sameDomain";
        params.allowfullscreen = "true";
        params.wmode = "transparent";
        var attributes = {};
        attributes.id = "AcpAs3";
        attributes.name = "AcpAs3";
        attributes.align = "left";
        swfobject.embedSWF(
            "AcpAs3.swf", "flashContent", 
            "100%", "100%", 
            swfVersionStr, xiSwfUrlStr, 
            flashvars, params, attributes);
        // JavaScript enabled so display the flashContent div in case it is not replaced with a swf object.
        swfobject.createCSS("#flashContent", "display:block;text-align:left;");
    </script>  
<head><br/>
<body><br/>
<h1>Look at My Model</h1>
    <div id="flashContent">
        <p>
            To view this page ensure that Adobe Flash Player version 
            11.1.0 or greater is installed. 
        </p>
        <script type="text/javascript"> 
            var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://"); 
            document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='" 
                + pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' 
                      alt='Get Adobe Flash player' /></a>" );
        </script>
    <div>
</body>
</html>

Step 4 - A Couple More Tweaks

Now we are getting close to being finished. Just a couple more tweaks.

  • Edit the path to the swfObject.js file in <head> of your html page from this:
<script type="text/javascript"> src="swfobject.js"</script>

...to this (type/paste the code below):

<script type="text/javascript">
src="https://www.analyticacloud.com/acp/clientAs3/swfobject.js"</script>
  • Continuing with the script in the <head>, we need to edit the link to the shockwave file to that shown below:

before:

swfobject.embedSWF(
    "AcpAs3.swf", "flashContent", 
    "100%", "100%",

after:

swfobject.embedSWF(
    "https://www.analyticacloud.com/acp/ClientAs3/AcpAs3.swf","flashContent", 
    "100%", "100%",

Step 5 - Optional - Set the size for the ACP rectangle on your web page

  • In the previous line of code you can substitute your desired width and height for the ACP rectangle on your web site e.g.:
"400", "300", to replace the "100%", "100%",

Step 6 - Time to test it

So now you can try saving the html file and loading this page onto your web server and then loading the page in a browser window. Hopefully, it will display your model below the page’s title something like this:

ACP in a web page 9 finished.png

Summary

Hopefully these examples are a clear enough demonstration of how to play a model on a web page on your site by either using an iframe or using some Javascript code.

If you have questions, or if something isn’t working, please email us at acp@lumina.com and we will be happy to help you out.

See Also

Comments


You are not allowed to post comments.