<center>
<button type= "button" onclick="myFunction()">Things To Do in Miami</button>
<div id="loadiframehere">
<iframe id="myframe"src="https://thingstodo.expedia.com/miami-florida-activities/" width="450" height="275" > </iframe>
</div>
</button>
<script>
function myfunction(){
var x = document.createElement("IFRAME")
set.attribute("src","http://www.miamigov.com/home/");
set.attribute("width","600")
set.attribute("height","400")
document.getElementByID("myframe").src="http://www.miamigov.com/home/"
document.getElementByID("myframe").width="300";
document.getElementByID("LOADHERE").appendchild(x);
}
</script>
</center>
</section>
이것은 선생님이 복사 해 준 코드이지만 버튼이 작동하지 않습니다. iframe은 단추를 클릭하기 전에 옆에 나타납니다.버튼을 클릭하면 iframe이 어떻게 나타나게합니까?
set.attribute 부분 나던 것은 말이. 제 생각에는 x.setAttribute ("src", "http://www.miamigov.com/home/"); 그리고 "LOADHERE"ID가 없습니다. 아마도 "loadiframehere"일 것입니다. – TheWandererr
처음부터 숨기려면 아무 것도하지 않았습니다. 이미 표시되어있을 때 무언가를 표시 할 수 없습니다. – charlietfl
그래도 해결되었지만 여전히 작동하지 않습니다. 하지만 고마워. – Leslievramirez