title: Opening different iframe depending on different button click
body: <p>i am trying to open different iframe windows by assigning iframe src to a variable ,
  when the page initially loads it should show only two buttons on the page , when i click on the button , an iframe should get loaded depending on which button is pressed , i tried doing something like this to create buttons and creating iframes , but it is not working</p>
  
  <pre><code>&lt;button id="b1"&gt;Button 1&lt;/button&gt;
  &lt;button id="b2"&gt;Button 2&lt;/button&gt;
  &lt;iframe scrolling="no" src="whatnext"&gt;
  &lt;/iframe&gt;
  &lt;script&gt;
  var b1 = document.getElementById('b1'), b2 = document.getElementById('b2');
  var x = "Hello!";
  function showX() {
      var whatnext;
      if b1.onclick==true
          whatnext= "http://community.sitepoint.com/" style="border: 0px none; height: 1555px; margin-left: -116px; margin-top: -25px; width: 930px;"
          elseif b2.onclick=true
          whatnext= "http://community.sitepoint.com/" style="border: 0px none; height: 555px; margin-left: -116px; margin-top: -25px; width: 330px;"
  }
  &lt;/script&gt;
  and another piece of trial is
  &lt;button id="b1"&gt;Button 1&lt;/button&gt;
  &lt;button id="b2"&gt;Button 2&lt;/button&gt;
  &lt;iframe scrolling="no" src="x" style="border: 0px none; height: 1555px; margin-left: -116px; margin-top: -25px; width: 930px;"&gt;
  &lt;/iframe&gt;
  &lt;script&gt;
  var b1 = document.getElementById('b1'), b2 = document.getElementById('b2');
  var x ;
  function showX() {
      src="https:http://stackoverflow.com";
  }
  b1.onclick = function() {
      x = "http://stackoverflow.com;
      showX();
  };
  b2.onclick = function() {
      x = "www.sitepoint.com";
      showX();
  };
  &lt;/script&gt;
  </code></pre>