Forum Moderators: open

Message Too Old, No Replies

move page within iframe down a bit

         

jackvull

8:36 pm on Mar 16, 2009 (gmt 0)

10+ Year Member



I have an iframe that displays a group on Facebook.
What I want to do is move the page within the iframe down about 100px as soon as it loads. As I don't own the facebook I can't put a script there.
Anyway to do this?

PHP_Chimp

2:20 pm on Mar 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could you not use some CSS to do it?

Something like the below if you want to set the css with javascript:


element.style.padding = '100px 0 0 0';
// or
element.style.paddingTop = '100px';

jackvull

2:27 pm on Mar 17, 2009 (gmt 0)

10+ Year Member



Doesn't seem to work because to move the page within the iframe down, I have to do something like:
style = 'padding: -100px 0 0 0;'
and then it doesn't move because negatives are not allowed with padding or padding-top
Works if I have +100 but then that's the wrong way

PHP_Chimp

4:48 pm on Mar 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hummmm, adding a +iv padding to the top should move the contents of that element down by that amount. I have just tested to make sure I wasnt being an idiot and

element.style.padding = '100px 0 0 0';
works fine.

Are you applying the padding to the iframe, or another element?
As you need to apply it to the iframe, so that all contents of the iframe will start 100px lower down.

I suppose you could always put all of the iframe contents within a div and relatively position that div to be 100px lower than the iframe. Although I dont see why adding padding to the iframe is not working...

jackvull

4:52 pm on Mar 17, 2009 (gmt 0)

10+ Year Member



The padding moves the whole page down, what I need to do is the equivalent of scrolling down which is actually moving the page UP in your example. I'll PM you the website.
I'll try the div...
Basically, I don;t want the facebook banner and stuff displayed in the iframe, I just want the images of the gallery...

Fotiman

5:26 pm on Mar 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think you are looking for this:

window.scrollBy(horizPixels, vertPixels);

So in your case, it would be something like this:

window.scrollBy(0, 100);

jackvull

5:34 pm on Mar 17, 2009 (gmt 0)

10+ Year Member



Nope, that scrolls the parent rather than the iframe:

<iframe scrolling='no'
src='http://www.facebook.com/photo_search.php?oid=1071510610&view=all'
border=0
width = '700'
height ='860'
onLoad='window.scrollBy(0, 100);' >
</iframe>

NOR


<body onLoad='document.getElementById("myframe").window.scrollBy(0, 100);'>
<div id="content">
<div id="colOne">
<div class="post">

<iframe scrolling='no'
src='http://www.facebook.com/photo_search.php?oid=1071510610&view=all'
border=0
width = '700'
height ='860'
name='myframe'
id='myframe' >
</iframe>

</div>
</div>
</div>

PHP_Chimp

6:54 pm on Mar 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ahh I think I now understand.

I take it you want to scroll the iframe's contents so that the facebook banner at the top isnt visible?

I'm not sure if you will be able to get rid of that banner completely. As even if you set the scroll bars to start at a set position not showing the banner then people will always be able to scroll back to the top and see it.

You cant just get rid of that banner, as their is no way to control the contents of another domain.

I suppose you could just stick an image of something else over the top to cover it up.
However why dont you want people to see that the pics come from facebook? It looks like a club site, so surely you want people to be able to join a facebook group about the club.

jackvull

10:47 am on Mar 19, 2009 (gmt 0)

10+ Year Member



Yes, but it's a gallery page and I'm just using the facebook group for the gallery. So, I don't mind a scroll bar being there but I want it to scroll down immediately to the pictures so it's all nicely centred.
If users want to scroll up they can but only after.
:)

jackvull

1:53 am on Mar 28, 2009 (gmt 0)

10+ Year Member



Any ideas?