상세 컨텐츠

본문 제목

how to use Iframe / change src in iframe?

개발생활/JavaScript

by 한국인맛집 2019. 1. 3. 13:55

본문

반응형

<iframe> Tag usage



Iframe tag

<iframe id="my-iframe" src="https://www.your.iframe.domain.src"></iframe>




Javascript change iframe src

$(document).ready(function(){

  document.getElementById('my-iframe').src="https://wantbe.tistory.com";

});





button click change iframe src 


<html>
   <head> </head>

   <body>
          <button id="my-btn" onClick="changeIframe()" >Click Me</button>
          <iframe src="" id="my-iframe"></iframe>
   </body>
</html>

<script>
  function changeIframe(){
    alert('Changed ! Iframe");
   document.getElementById('my-iframe').src="https://wantbe.tistory.com";
}


</script>



반응형

관련글 더보기