More

Embeds with iFrames and Scripts in CartoDB InfoWindows


How is it possible to embed content - like YouTube-Videos, Twitter-Tweets, Facebook-Posts, Instagram-Photos or any other kind of embeds - into a InfoWindow in CartoDB?

In my Dataset there is a row with the embed-code (iframe, script etc.) and I included the field into the infowindow via the CartoDB-Wizard… I know CartoDB blocks every script etc.… but there should be something like a "sanitizeTemplate" through CartoDB.js (as this was posted from someone in another question) - but I'm not able to get this working properly… can someone help me please?… with a detailed/full example?


By using CartoDB.js you can set sanitizeTemplate as false in order to run your scripts inside custom infowindows.

An example:

cartodb.createVis('map', 'viz_json', {options}) .done(function(vis, layers) { var d = layers[1].getSubLayer(0); d.infowindow.set({sanitizeTemplate:false}); d.infowindow.set("template", function(g) {… });