Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scroll iFrame to the right upon load

Status
Not open for further replies.

upiorz

Technical User
Mar 18, 2008
2
0
0
MX
Hi I'm searching for a script to shift (scroll) the contents of an iFrame 50 pixels towards the right upon loading.

In a nutshell the iFrame will be loading a 200x50px picture, the iFrame is only 150px wide with it's scrollbars disabled and I would like the pic to be showing it's right side (scrolled 50px to the right upon load).

Here's how far I got (I know it's not much)

<iframe src=" align="right" frameborder="0" marginwidth="1" marginheight="0" scrolling="No" width="150" height="50" ></iframe>

I thought align="right" would do the trick but didn't work

If anybody knows of a good tut or a code snippet that could help, I would greatly appreciate anything.

Thanks in advance.

Diego.-
 
I'll assume there's a reasonable explanation as to why you wouldn't simply make the iframe bigger or the picture smaller.

Use the [tt]window.scrollBy(intPixelsX, inPixelsY)[/tt] method to scroll your frame.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
Thanks dwarfthrower, there is indeed a reason for this... I want the entire contents in the iFrame to show the right side first (not the whole thing).

So I tried the following:
Code:
<body>
   <iframe name="pictureBox" src="[URL unfurl="true"]http://www.site.com/pictureBox.htm"[/URL] frameborder="0" scrolling="auto" >
   </iframe>
   <script type="text/javascript">window.frames["pictureBox"].scrollBy(50, 0);</script>
</body>

not working, am I missing something?

I also tried putting this in the loaded html (pictureBox.htm):
Code:
<body>
<script type="text/javascript">document.body.onload.scrollLeft = 50;</script>
</body>
...nothing :-(

If anybody has any ideas, I'll try anything...
Thnx again.

Diego.-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top