I have a standard FloatBox opening a webpage inside an iframe.
Is there any way to define the position of the page within the iframe? I would like to have the scroll position about halfway down the page.
I read elsewhere on the forum that someone was doing this with an anchor text and was having issues. This may be a solution for me if it works, however I don't own the websites I'm linking to so requesting an anchor text would be my second choice.
Ideally I am hoping there is some kind of setting or edit I could make to load the page within the iframe at say 1000px down the page.
Thank you for your help!
Scroll Position of Content within iFrame
Page: 1
Author | Post |
---|---|
#1 Wed Sep 05, 2012 9:35 pm
|
|
Member
Registered: Sep 2012
Posts: 1
|
|
#2 Thu Sep 06, 2012 2:11 am
|
|
Administrator
Registered: Aug 2008
Posts: 3382
|
Opening iframe content with #hash location on it indeed does not help in positioning the initially scroll state of the freshly loaded floatbox.
You can use the afterItemStart callback to do the scrolling. The simplest way would be to scroll a specific pixel amount. For example, the data-fb-options attribute for the link that initiates the floatbox could contain "afterBoxStart:`fb.getIframeWindow().scrollTo(0, 999)`". Scrolling to a specific pixel location is not so good. Different browsers layout pages differently, and folks can be using different font-sizes or zoom settings that would throw things off. We can get fancier by getting a reference to a particular element in the iframed page, locating that element in the window, and scrolling to that location. Here's some sample code that shows how that might be done: <script> However, you did say "I don't own the websites I'm linking to". If these are cross-domain websites, i.e., they come from different domains than the one your page is being served from, then there is no hope and nothing will work. No browser will execute javascript across domain boundaries. It is the foreign page that scrolls, not the local floatbox that contains it. |
Page: 1