【问题标题】:iframe src full width and heightiframe src 全宽和全高
【发布时间】:2017-08-04 17:29:21
【问题描述】:

我怎样才能使 iframe src 成为全宽和全高?

例如我有这样的 iframe

<iframe scrolling="no" frameborder="0" allowtransparency="true" style="border:none;width:100%;height:100&;" allowfullscreen="" src="http://www.example.com/page.php?width=100%&height=100%"></iframe>

这将只有iframe 的全尺寸宽度和高度。

如你所见page.php?width=100%&amp;height=100%

如果我一直这样,它就行不通了。即使我把它变成这样 page.php?width=auto&amp;height=auto

我需要什么来做这个 page.php?width=100%&amp;height=100% 去完整的 iframe 宽度和高度,因为如果我像这样更改大小,page.php 的内容将被调整大小page.php?width=200&amp;height=200

请任何人帮助我。欣赏一下

【问题讨论】:

  • @charlietfl 好吧,你给了我一个内容样式的想法,是的,我可以控制该内容,所以我几乎就在那里并且它工作了:D 非常感谢

标签: javascript php html css iframe


【解决方案1】:

传递 url 查询是一个开始,但您需要使用该信息来设置页面样式:

src="page.php?fullscreen=true"

这只是您可以尝试的粗略示例,您可能希望根据需要更改样式。

<?php if (!empty($_GET['fullscreen'])) {?>
<style>
html, body {
  height:100%;
  width:100%;
}
</style>
<?php } ?>

你可以做一些类似的事情,独立地传递宽度和高度,然后在 css 中使用这些值:

src="page.php?width=500&amp;height=400"

<?php if (!empty($_GET['width']) && !empty($_GET['height'])) {?>
<style>
html, body {
  height:<?php echo $_GET['height']; ?>px;
  width:<?php echo $_GET['width']; ?>px;
}
</style>
<?php } ?>

【讨论】:

  • 感谢您花时间编写所有这些,但我已经用@charlietfl is sulition 修复了它。再次感谢
  • 好吧,由于他的答案或评论在这里不可见,您至少应该编辑您的答案以显示解决方案,或者尝试此操作并将其标记为已解决...。这将对其他人有所帮助未来。
猜你喜欢
  • 1970-01-01
  • 2012-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-28
  • 1970-01-01
  • 2021-10-19
相关资源
最近更新 更多