<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은 버튼을 클릭하기 전에 그 옆에만 나타납니다.
여기 수정이 있습니다. 귀하의 코드는 완전히 잘못되었습니다. Javascript는 대소 문자를 구분한다는 점을 알고 있어야합니다. getElementByID는 getElementById와 다릅니다.
또한 iframe이되도록 "x"요소를 만들었지 만 html에서 iframe도 만들었고 "set"속성이 어떤 요소에도 연결되지 않았습니다. "myFunction"이라는 함수를 만들었지 만 buttong에서 "myfunction"을 호출했습니다. 다시 말하지만, javascript는 대소 문자를 구분 합니다.
자바 스크립트 구문을 공부해야합니다.
function myfunction(){
var x = document.createElement("IFRAME");
x.setAttribute("src","http://www.miamigov.com/home/");
x.setAttribute("width","600");
x.setAttribute("height","400");
document.getElementById("loadiframehere").appendChild(x);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<center>
<button type= "button" onclick="myfunction()">Things To Do in Miami</button>
<div id="loadiframehere">
</div>
</center>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다