<<Back
Iframe Sample
This sample loads the presentation data for the recommendations in an iframe.
  • A page is created - for example recommendationspage.php - that takes an array of product identifiers as query string. The purpose of the page is only to display recommendations.
  • After the recommendations have been delivered from Avail BEM the recommendation presentation page is loaded in the iframe.
  • <html> <head> <script type="text/javascript" charset="UTF-8" src="http://service.avail.net/2009-02-13/dynamic/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/emark.js"></script> <script type="text/javascript"> function populatePredictions(){ var emark = new Emark(); var recommendedProducts = emark.getRecommendations("myTemplate", ["ProductIds:myProductId1,myProductId2,myProductId3"]); emark.commit(function() { var url = "http://www.mysite.com/recommendationspage.php?ProductIds=" + recommendedProducts; document.getElementById("RecsIframe").src = url; }); } </script> </head> <body onload="populatePredictions();"> <b>Test Page</b><br /> <iframe id="RecsIframe" src="" height="400" width="135" frameborder="0" scrolling="no"></iframe> </body> </html>
    The page http://www.mysite.com/recommendationspage.php would load a page that would look something like below image.