analytics/assets/js/embed.host.js
Uku Taht 7d37208d52
Allow custom styles to be passed to embedded iframe (#1522)
* Allow custom styles to be passed to embedded iframe

* Changelog
2021-12-08 11:53:37 +02:00

21 lines
414 B
JavaScript

import iframeResize from 'iframe-resizer/js/iframeResizer'
var iframes = iframeResize({
heightCalculationMethod: 'taggedElement',
onInit: onInit
}, '[plausible-embed]')
function onInit() {
var iframe = iframes[0]
var styles = iframe.getAttribute('styles')
if (styles) {
iframe.iFrameResizer.sendMessage({
type: 'load-custom-styles',
opts: {
styles: styles
}
})
}
}