When using the Integration Theme please refer to the topic Integration Theme Live for more information.
Overcoming Third Party Cookie issues with iframes
Inline frames are specified within your site by using the <iframe> tag.
The src attribute of the <iframe> tag provides the URL to the DriveWorks Live site to present within the inline frame.
Cookies used on sites referenced by an inline frame become third party, which most browsers block by default.
To overcome this your DriveWorks Live site must be a sub domain of your website.
Assistance in setting up your DriveWorks Live site to be a sub domain should be provided by your ISP or IT technician.
Integration Theme
We strongly recommend using the Integration Theme when passing data from a Website.
The Integration Theme provides a more robust and appealing experience with more features and a superior security model for this type of integration.
Please visit the Integration Theme Help file for more information and benefits.
DriveWorks can be placed in an IFrame, in an existing website, and data can be passed to it through the Integration Module.
Data is passed to the IFrame through a URL. However, this does have some limitations:
These limitations are solved by the implementation of postMessage in the Specification Form Module.
If you had customized this file prior to this service pack, please migrate your changes to the latest version installed with this (or a newer) service pack.
The image below shows an example of a website (area within the red border) that uses an IFrame (area within the blue border) to push data to a running specification.
Here the running specification contains a 3D Preview control only.
The data being pushed to the specification (Strap Color, Case Material, Face Markers, etc.) will update the 3D file in the running specification.
Implementing this does require code to be written on the web page hosting the IFrame. Example code is given later in this topic.
DriveWorks utilizes postMessage which allows safe communication between a parent web page and DriveWorks Live.
The page in the IFrame (the DriveWorks Live specification) listens for a message event.
Once received from the expected URL (the site hosting the IFrame) it will send the data it received to the Integration Module, using the session data available to the window within the IFrame.
When the specification running in the IFrame is ran through IIS it is important to have Web Sockets enabled, see section 7. Enable Web Sockets for more information.
The Specification Form module is required to have the following settings applied:
This is the relative path or full URL of the integration module to pass parameters to.
If the value of this setting does not begin with http:// or https://, then DriveWorks will treat this as a relative value, and automatically resolve it.
So, if DriveWorks Live is running at:
http://driveworkslive.mydomain.com
and the value /Integration is passed, this will automatically become:
http://driveworkslive.mydomain.com/Integration
Using the same example, any of the three following values would also be resolved:
This is the URL of the parent site hosting the specification in the IFrame, as this is what should be sending the postMessage events to the running Specification.
If this does not match the site that is sending the messages, then nothing will happen to the specification.
This prevents unauthorized domains from seeing the response data that comes back from communicating with the specification (if a call into the code from outside the trusted domain was made).
For information on how to navigate to and apply the above settings please see Specification Form.
This is the part where a little bit of code is required to be written in the web page where the IFrame will be hosted.
The example code below is a very simple html web page, that contains:
<iframe id="MyFrame" height="1000" width="1500" src="http://driveworkslive.mydomain.com/Apps/MyProject" ></iframe> <script> // The params element below should be replaced with the parameters to be driven - see below for examples function sendIntegrationParams(params) { // MyFrame below must be the same name declared in the iframe id above var iFrame = document.getElementById("MyFrame").contentWindow; // The second parameter below must be the URL where the content of the IFrame is hosted iFrame.postMessage(params, "http://driveworkslive.mydomain.com"); } </script>
Further explanation of the tags and elements used in the code above are given below:
This tag includes the following elements:
This is any name used to identify the IFrame. This is also given in the getElementById value.
For example: id="MyFrame"
This is the required height for the IFrame.
For example: height="1000"
This is the required width for the IFrame.
For example: width="1500"
This is the URL to the project to be run as a specification.
For example: http://driveworkslive.mydomain.com/Apps/MyProject
The word params should be replaced with all the parameters that are required to be driven.
The param string is made up of the following:
For example: "?StrapColor=Green&CaseMaterial=Steel&FaceMarkers=Light"
<iframe id="MyFrame" height="1000" width="1500"></iframe> <button id="Light">Light</button> <button id="Dark">Dark</button> // There is some JavaScript on that page that adds event handlers to the buttons: <script> // Set a default color value var defaultColor = "Light"; // Set the src of the IFrame to run our project via the Integration Module so we can pass in an initial value dynamically document.getElementById("MyFrame").src = "http://driveworkslive.mydomain.com/integration?FaceMarker=" + defaultColor; // Get hold of all of the color buttons var LightButton = document.getElementById("Light"); var DarkButton = document.getElementById("Dark"); // Put the FaceMarker buttons in an array var buttons = [LightButton, DarkButton]; // Loop over all of the buttons buttons.forEach(function(button) { // Add a click event handler to the button button.addEventListener("click", function(e) { // Get hold of the id of the button to get the name of the color var color = e.target.id; // Send the new color to the IFrame to be applied to the running spec sendIntegrationParams("?FaceMarker=" + color); }); }); </script>
If a different Project than that set in the Integration Module is required, or the Default Project Name does not have a value applied, the Project Name will be required as a parameter (line 9 in the example above).
For example, if the Default Project Name had not been set, or was not set to "MyProject" but that is what you are displaying in the IFrame, then the parameter string above would become:
"?Run=MyProject&FaceMarker=" + color
The value "MyFrame" should be replaced with the name decalred in the id element of the iframe tag above.
This must be the URL of where the content of the IFrame is hosted.
For example: "http://driveworkslive.mydomain.com"
If you have followed the above and your setting for the Expected Origin URL in the Specification form module matches the origin of the message being sent, then everything should work as expected.
Knowledge Base Article Ref: | KB18111901 |
---|