set position of scrollbar in an iframe

Asked

Viewed 367 times

1

I have a #iframe page, and when the page loads, I need the iframe scroll to slide horizontally to the end (to the right).

I tried several ways but so far nothing.

jQuery("#iframe").contents().find("html,body").animate({scrollLeft:100}, 1000);

Someone would help me ?

  • It is an iframe of an internal or external url?

  • an internal url ! (action=".. /test/index.php")

1 answer

0

You almost got.

Test just add your code on $(window).load() and see what happens.

$(window).load(function(){
    jQuery("#iframe").contents().find("html,body").animate({scrollLeft:100}, 1000);
});

See a functional example

Remember that there may be some security blocks in the iframe, thus preventing the operation.

For more information, see this question, that I think will help you a lot.

  • great tip ! But I couldn’t make it work yet !

  • I can’t access iframe by scrollLeft() function, I can’t get scroll position, follow link http://westlucaya.com/index.php/br/status-e-mapa-local

Browser other questions tagged

You are not signed in. Login or sign up in order to post.