Trouble repositioning an external file in an iframe

M

Mark

I want to have an iframe containing an external document in it that I can
resize, crop, and reposition in any way, but some things aren't working as
expected. Specifically, I have been unable to programmatically reposition
the external file so that the part that shows through the iframe is not the
top part. Also, I have been unable to determine how long the file is as it
sits in the iframe.

Say I have an iframe called "pageFrame" that is 100 pixels high by 200
pixels wide, into which I have read a lengthy file called "someFile.html".
I want "pageFrame" to show the portion of "someFile.html" from pixel 400 to
pixel 499 vertically (i.e. like the 5th page) completely through
programming, with no built-in scrollbar. The following drawing will
hopefully help if it's not too distorted.

<---------- 200 px ------------->

##########################
^
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
696 px
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
| | ^
|
| | |
|
| iFrame viewport | 100 px
|
| | |
|
| | V
| ##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
|
##########################
V

So far I have been able to define, size, & position the iframe anywhere in
the window, as well as load in the external file. I've also been able to
'temporarily' reposition the file inside the iframe with:

pageFrame.document.body.scrollTop = 400;

and stopping things with an alert message. This lets me see that the file
was read in and repositioned as specified, but as soon as I close the alert
box the file reverts to its original position at the top of the iframe even
though I haven't coded it to do this.. Furthermore, even this temporary
repositioning doesn't work when I first load the file, only when I refresh
or resize.

I also want to obtain the "inner height" of the external file as it fits in
the iframe. For example, this file "someFile.html" might occupy 696
vertical pixels inside the iframe. I thought I could get this with one of
the following statements:

document.getElementById('pageFrame').offsetHeight
document.getElementById('pageFrame').scrollHeight

but these both return the same value, namely the height of the iframe, in
this example 100, rather than 696.

BTW: I'm doing this for IE 5+ right now and will take it to NS 6 later.

Can anyone help? There just doesn't seem to be a comprehensive resource for
Javascript.

Thanks.

- Mark.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top