iframe设置高度为100%

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <style>
  * {
    padding: 0;
    margin: 0;
  }
  
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  </style>
</head>

<body>
  <iframe id="ajk" width="100%" height="100%" src="http://dulijingjiren18.anjuke.com/gongsi-jjr-3435066/com161133/#afilters" frameborder="0"></iframe>
  <script>
  var ajk = document.querySelector('#ajk');
  var screenHeight, scrillWidth;

  window.onresize = function() {
    screenHeight = document.body.clientHeight;
    scrillWidth = document.body.clientWidth;
    ajk.height = screenHeight;
    if (scrillWidth <= 768) {
      ajk.src = "https://m.anjuke.com/hz/jjr-3435066/com161133/"
    } else {
      ajk.src = "http://dulijingjiren18.anjuke.com/gongsi-jjr-3435066/com161133/#afilters"
    }
  }
  </script>
</body>

</html>

当屏幕为手机屏幕时切换url,pc端时让网页100%显示

posted @ 2017-05-19 14:27  wmui  阅读(878)  评论(0编辑  收藏  举报