Menachem
Menachem

Reputation: 173

iframe-resizer: ScrollTo() works, but ScrollToOffset() does not

I'm running iframe resizer 3.5.3 on a wordpress installation. I can't say I really know what I'm doing, but I did a lot of reading and googling online, and got iframe-resizer up and running.

My iframe is embedded in the middle of the page, so I used scrollTo() to get it to scroll down to the iframe. See code below:

 <script type="text/javascript" src="/wp-content/uploads/iframeresizer/iframeResizer.min.js"></script> 
 <script type="text/javascript">
      iFrameResize( { minHeight : 1000, log : true, InPageLinks : true,   
      initCallback: function() { scrollTo(0,1000); }                                 
      } );
 </script>

This worked, but scrollToOffset() did not. I can't figure out why one should work while the other does not. Here is the code:

 <script type="text/javascript" src="/wp-content/uploads/iframeresizer/iframeResizer.min.js"></script> 
 <script type="text/javascript">
      iFrameResize( { minHeight : 1000, log : true, InPageLinks : true,   
      initCallback: function() { scrollToOffset(1,1); }                                 
      } );
 </script>

Any reason why one should work while the other doesn't? Am I doing something wrong?

Upvotes: 0

Views: 1009

Answers (1)

David Bradshaw
David Bradshaw

Reputation: 13077

The two methods should be called from inside the iFrame, not from the callbacks.

scrollTo works because you are calling the native window.scrollTo method, rather than the iframeResizer one.

Upvotes: 0

Related Questions