How can i make iframes show hide when button is clicked?

ozzy t
ozzy t used Ask the Experts™
on
I have 2 iframes and i would like to show hide them when i click on buttons, i have the jquery working but i have to change it to javascript because of some browser issues. What javascript code can i use to accomplish this, i have tried different methods but i can't seem to make it work. I am not very proficient wih javascript yet and any help or suggestion would be greatly appreciated. Thank You.
iframe.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Take a look at this code. Note, the iframe elements now have id attribute. Also I put the iframe size attributes inside the style attribute.
<div class="panel1">
<iframe id="content" class="content" src="<?php echo get_trusted_url('tabadmin','mainreportsvr:8000','views/MasterProviderDailyProductivity/Story1')?>"
style="width:1500px; height:800px; border:0;display:none" >
</iframe> 
 </div>


<div class="panel2">
<iframe id="content2"  class="content2" src="<?php echo get_trusted_url('tabadmin','mainreportsvr:8000','views/MasterSiteDailyProductivity-copy/Story1')?>"
  style="width:1500px; height:800px; border:0;display:none" >
</iframe>  
</div>

 <script type="text/javascript">

window.addEventListener("load", function(){
  document.getElementById("hideshow").addEventListener("click", function(){
      var st = document.getElementById("content").style;
      if( st.display == "block" )
          st.display = "none";
      else if( st.display == "none" )
          st.display = "block";
    });
  document.getElementById("hideshow2").addEventListener("click", function(){
      var st = document.getElementById("content2").style;
      if( st.display == "block" )
          st.display = "none";
      else if( st.display == "none" )
          st.display = "block";
    });
});
</script>

Open in new window


jQuery is a quite good library. If it has issues with some environment, it's better to solve the issue somehow rather than not use it.
ozzy tDeveloper/Health Informatics

Author

Commented:
Thank you i appreciate you taking time to help me with this!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial