dqask02082
dqask02082
2017-08-04 17:29
浏览 64

iframe src全宽和高度

how can i make iframe src to full width and height ?

for example i have iframe like this

<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>

this is just gonna have full size width and height of iframe only.

as you see this part page.php?width=100%&height=100%

if i keep it like that, it won't work. even if i make it like this page.php?width=auto&height=auto

what i need here to make this page.php?width=100%&height=100% to go full iframe width and height because the content of page.php will be resized if i change the size like this page.php?width=200&height=200

anyone help me with this please. appreciate it

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsa45664
    dsa45664 2017-08-04 17:38
    已采纳

    Well passing the url query is a start but you need to use that information to give the page styling:

    src="page.php?fullscreen=true"

    This is just a rough example of what you might try, you may want to change the styles depending on whats necessary for you.

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

    You could do something similar passing in width and height independently and then using those values in the css:

    src="page.php?width=500&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 } ?>
    
    点赞 评论

相关推荐