问题
If there is no content to display (ad banner delivered by external server), i want hide the iframe (e.g the div that includes the iframe). This is what i have so far, but it is not working. Other solutions had the "cross-origin" problem.
Iframe hidden by default, check if external .php available. If yes, display it.
<script>
$.get('https://www.external-example.com/subolder/myid.php', function(data, textStatus, jqxhr) {
// make the ad visible
$('#iframe-container').show();
});
</script>
<div id="iframe-container" style="visibility: hidden;">
<div style="display:inline-block;width:auto;height:auto;">
<iframe src="https://www.external-example.com/subolder/myid.php" style="background-color: white;border: 0;height: auto;text-align:center;width: auto;max-height: 100%;" scrolling="no"></iframe>
</div>
</div>
*script example from: How do hide div if ad does not appear
来源:https://stackoverflow.com/questions/59299717/show-iframe-if-external-php-is-available-only-else-hide-it