How to autoscroll to the end of iframe using JavaScript (or jQuery)?
<p>I have the following code:</p>

<pre><code>&lt;iframe id="preview" onLoad="scrollToBottom()"&gt;&lt;/iframe&gt;
</code></pre>

<p>My objective - When the frame reloads, the "scrollToBottom()" function is triggered, which will take the user to the end of the iFrame (instead of the beginning of the frame, which is by default). The code I have now is:</p>

<pre><code>function scrollToBottom() {
    window.scrollTo(0, document.body.scrollHeight);

}
</code></pre>

<p>I know, somehow I have to figure/pass the scrollHeight of the iframe, but I am not sure how to do that. A solution in JavaScript or jQuery is what I want. There are a few solutions I saw here, but none of them are working for me. BTW...I don't need any animation or effects...just need a simple/plain solution.</p>

<p>Any help will be appreciated. Thanks in advance.</p>
