Opening different iframe depending on different button click - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Opening different iframe depending on different button click

Demo Code

ResultView the demo in separate window

<!doctype html>
<html>
   <head> 
      <script>
function loadFrame (elm){//from w  ww. j  av  a  2  s  . com
    var frame1 = document.getElementById('frame1');
    frame1.src = elm.dataset.src;
}

      </script> 
   </head> 
   <body> 
      <button id="b1" data-src="http://www.java2s.com" onclick="loadFrame(this)">Button 1</button> 
      <button id="b2" data-src="http://www.example.com" onclick="loadFrame(this)">Button 2</button> 
      <iframe id="frame1" scrolling="no"></iframe>  
   </body>
</html>

Related Tutorials