I have an iFrame with a pdf src. When I click a button it is shown. When I click a button it is hidden.
It is coded as a function using jquery .toggle (simplified):
Here is the solution:
JS-Fiddle: http://jsfiddle.net/hT97Z/3/
In this way the loading of the .pdf is isolated from the toggle function all together.
The code added to the function:
function showpdf() { $('.showpdf').toggle(); $('#theframe').attr('src','the.pdf'); }
The html added:
<iframe style="display:none;" src="the.pdf"></iframe>