I have a widget from truspilot that makes an iframe that I'm trying to make responsive. I've searched for hours on SO to find how to do this, but no solution seems to work for adjusting my height and width responsively.
Here is the widget
<div class="tp_-_box" data-tp-settings="domainId:3660907">
<a href="http://www.trustpilot.com/review/www.longtiestore.com" rel="nofollow" hidden>Long Tie Store Reviews</a>
</div>
<script type="text/javascript">
(function () { var a = "https:" == document.location.protocol ? "https://ssl.trustpilot.com" : "http://s.trustpilot.com", b = document.createElement("script"); b.type = "text/javascript"; b.async = true; b.src = a + "/tpelements/tp_elements_all.js"; var c = document.getElementsByTagName("script")[0]; c.parentNode.insertBefore(b, c) })();
</script>
I my iframe width is working fine with just:
iframe {width:100%}
but there is an element within the iframe that needs to be set to 100%
in order for the layout to work.
.tp-box {width:100%;}
But I can't stylize content within the iframe from the parent. So I've tried adding:
window.onload = function () {
if (parent) {
var oHead = document.getElementsByTagName("head")[0];
var arrStyleSheets = parent.document.getElementsByTagName("style");
for (var i = 0; i < arrStyleSheets.length; i++)
oHead.appendChild(arrStyleSheets[i].cloneNode(true));
}
}
but with no success.
So what can I do to make the width and height fluid?