iframe - 如果外部 .php 仅可用,则显示 iframe。其他:隐藏它
问题描述
如果没有要显示的内容(外部服务器提供的广告横幅),我想隐藏 iframe(例如包含 iframe 的 div)。这是我到目前为止所拥有的,但它不起作用。其他解决方案存在“跨域”问题。
iframe 默认隐藏,检查外部 .php 是否可用。如果是,请显示它。
<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>
*脚本示例来自:如果没有出现广告,如何隐藏 div
解决方案
推荐阅读
- mysql - 为什么我将所有值都视为 NULL?
- java - 一次搜索二维数组的多个方向
- mysql - 从满足条件的 MySQL JSON 列中选择行
- flutter - SocketException:操作系统错误:颤动时管道损坏
- html - 使用带有通用元素 html 的 Jaspersoft 中断页面
- javascript - 如何使用不同的数据集多次渲染 docxtemplater
- node.js - 从 node.js 中的 docker 容器备份 MongoDB 数据库
- python - Dataframe:如何将两列与字符串值进行比较?
- blockchain - Substrate 区块链框架中“已提交”和“已完成”交易的区别?
- python - 从 csv 数据在 python 中创建 NetCDF 文件