0

I have two iframes, iframe1 has buttons and iframe2 is supposed to display content if a button is clicked. Example if I click button1 on iframe1, button1.html content should be displayed inside iframe2 and if I click button2 which is on iframe1 then button2.html content should be displayed inside iframe2 (i.e. content which was on iframe1 should be substituted be content relative to each button). (I am using javascript, HTML and CSS only)

Pela647
  • 31
  • 9
  • Do both ` – guest271314 Dec 24 '16 at 19:49
  • I have solved the problem thank you for your concern!! – Pela647 Jan 01 '17 at 04:53

1 Answers1

0

The accepted answer for a similar question should allow you to detect button click events in an iframe. This will allow you to set the src attribute in the other iframe. Something like:

  $(document).ready(function(){
    let iframe_two = $("#two").contents();
    let iframe_one = $("#one");
    iframe_two.find("button").click(function(){ 
      iframe_one.attr("src", "https://www.reddit.com") 

    })
  })
Community
  • 1
  • 1
RedMage
  • 1,126
  • 1
  • 9
  • 21