在iFrame中隐藏元素

时间:2019-01-28 18:55:38

标签: javascript iframe bootstrap-4

以下是我尝试使用Javascript将jumbotron类隐藏在iframe中的尝试。我没有运气!

我的控制台中的错误是:

  

无法读取未定义的属性“样式”

我不明白为什么它不起作用-很抱歉,如果我在这里很愚蠢,实际上不是Java方面的佼佼者。任何帮助将不胜感激。

var iframe = document.getElementById("myFrame");
var elmnt = iframe.contentWindow.document.getElementsByClassName("jumbotron")[0];
elmnt.style.display = "none";
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">


<div class="container">
  <div class="row justify-content-center">
    <div class="col-8">
      <iframe id="myFrame" style="" width="100%" border="0" frameborder="0" src="https://remelo.com/booking/c/1/remelo" height="789"></iframe>
    </div>
  </div>
</div>

0 个答案:

没有答案
相关问题