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):
<script>
function showpdf() {
$('.showpdf').toggle();
}
</script>
<div class="showpdf" style="display:none">
<iframe class="showpdf" src="file.pdf" style="display:none;">
</iframe>
</div>
<div class="showpdf" style="display:none">Hide PDF</div>
<div class="showpdf" style="display:block">Show PDF</div>
This works fine in IE, Chrome, FF... But in Safari, the pdf does not hide.
JSFiddle: http://jsfiddle.net/hT97Z/
PS: can anyone explain why it does not work at all with onLoad, onDomReady?
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:
The html added: