Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8260329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:04:32+00:00 2026-06-08T03:04:32+00:00

I have the following code: <iframe id=preview onLoad=scrollToBottom()></iframe> My objective – When the frame

  • 0

I have the following code:

<iframe id="preview" onLoad="scrollToBottom()"></iframe>

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:

function scrollToBottom() {
    window.scrollTo(0, document.body.scrollHeight);

}

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.

Any help will be appreciated. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:04:33+00:00Added an answer on June 8, 2026 at 3:04 am

    The following method should work.

    $('#preview').contents().scrollTop($('#preview').contents().height());
    

    However, in this case, the iframe itself must from your domain or it throws an error

    Unsafe JavaScript attempt to access frame, Domains, protocols and
    ports must match.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have the following code which is doing a setInterval until the iframe
i have the following code var url = url; $('<iframe />', { name: 'frame',
I have the following code: <div style= class=skiptranslate> <iframe frameborder=0 style=visibility:visible src=javascript:'' class=goog-te-banner-frame skiptranslate
I have the following code to show <iframe src=http://www.facebook.com/plugins/like.php?href=[mySite] scrolling=no frameborder=0 style=border:none; width:170px; height:80px></iframe>
I have the following code: $embed_url = str_replace('<iframe width=512 height=288 frameborder=0 scrolling=no src=', '',
I am executing the following code in an iFrame: window.frames[0].location.reload(); It reloads the page,
I have a page with an Iframe. I am using the following code to
I have the following code: function callIframe(type, cat) { var send = false; var
I have the following code: <iframe> <div id=inner_div> Here's some text! </div> </iframe> I
I have the following jquery code working fine: $('iframe#captcha')[0].contentDocument.location.reload(true); $('input#captchainput').val(''); $('img#ajaxLoader').hide(); $('h3#loginFailed').show(); Is it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.