Hi I am building a simple website using bootstrap.
I want to have buttons which would change the src parameter of my iframe which is showing the pdf file. For example when I click on the button 2, I want to show the pdf2 in the iframe.
Here's what I have in the html:
<div class="btn-group" role="group" >
<button id="1" type="button" class="btn btn-default">Report 1</button>
<button id="2" type="button" class="btn btn-default" >Report 2</button>
<button id="3" type="button" class="btn btn-default">Report 3</button>
</div>
<div class="embed-responsive embed-responsive-16by9">
<iframe id="iframe" class="embed-responsive-item" src="reports\Report1.pdf"></iframe>
</div>
And this in the separate js file which I included. Please don't be so hard if I made some really obvious mistake cause I am a newbie. I tried to use some function I found here to force reloading of the website. It doesn't work
$(document).ready(function(){
$("#1").click(function(){
$("#iframe").attr("src", 'reports\Report1.pdf');
$("#iframe").contentWindow.location.reload(true);
});
$("#2").click(function(){
$("#iframe").attr("src", 'reports\Report2.pdf');
$("#iframe").contentWindow.location.reload(true);
});
$("#3").click(function(){
$("#iframe").attr("src", 'reports\Report3.pdf');
$("#iframe").contentWindow.location.reload(true);
});
});