iFrame von „fremder“ URL an Höhe des Inhalts anpassen


<iframe name="thetarget"
id="thetarget"
src=""
height="1000"
width="100%"
frameborder="0"
border ="0"
allowtransparency="true"
onload="scroll(0,0);"
scrolling="no">
</iframe>

<script type="text/javascript">
var IFrameID = "thetarget";
var domain = "https://woher-auch-immer.com";
var path = "/de/";

window.onload = function(e) {
var theIframe = document.getElementById(IFrameID);
theIframe.src = domain + path + window.location.search;
};

function updateIFrame( height ) {
var theIframe = document.getElementById(IFrameID);
theIframe.setAttribute( 'height', height );
}

function receiveMessage(event) {
if (event.origin == domain) {
if(typeof event.data === "number") {
updateIFrame(event.data);
}
} else {
return false;
}
}

if (typeof window.addEventListener != "undefined") {
window.addEventListener("message", receiveMessage, false);
}
</script>