Clinking on <a> changes iframe SRC. Need to be clicked 2 times to work
Closed this issue · 2 comments
I have a iframe where the src is changed whenever a anchor tag is clicked. I have " $('iframe').iframeAutoHeight();" in the function but it seems like I need to click the anchor a second time in order for the iframe to be resized correctly. Any ideas for a fix? seems to be doing it across all browsers. Thanks!
The $('iframe').iframeAutoHeight();
call does not cause the iframe to resize - it wires up the load
event of the iframe to call the resize. So try using one of the below techniques to initialize the resizing
<!-- with document ready, most likely in the html head -->
<script>
$(document).ready(function () {
$('iframe').iframeAutoHeight({debug: true});
});
</script>
<!-- inline, after the iframe -->
<iframe src="my_iframe.html" class="auto-height" scrolling="no" frameborder="0"></iframe>
<script>
$('iframe.auto-height').iframeAutoHeight({minHeight: 240});
</script>
Then in the code for your <a>
just set the src
- once it loads the new src into the iframe that should cause the iframe load
event to fire and that should cause the resizing to occur - it should 'just work'
Worked perfect! Thanks so much!