There's a <iframe>
element from external site, containing a textarea
, in one of my blogger posts. I already added couple more posts after that. But when I open the site, the blog scrolls down to the <iframe>
becuase it posseses the focus. How to prevent this so that when the blog is opened, the latest post can be seen?
This is how I added the iframe
in the blog post.
<iframe border="no" allowtransparency="true" height="500" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="some external site reference" width="100%">
</iframe>
FYI, the blogger has dynamic views
template.
I tried using scrollTo()
, focus()
to the latest post header. But it didn't work. I found that even if I print the count of article headers inside $(document).ready()
, it returns 0. After the page fully loads, if I go to the console and re-print the length, only then it gives 10. Quite confused about how the blogger handles its posts.
<script> $(document).ready(function(){ console.log( $('div.article-header').length ); // returns 0 }); </script>
Update
It looks like Blogger Dynamic Views loads the blog posts using AJAX. As a consequence, the document ready() gets called before the actual blog contents are fully loaded. 'Jeffery To' has given a good explanation about this below:
prettyPrint() doesn't get called on page load
Thanks.