Forum Moderators: open

Message Too Old, No Replies

Setting IFrame height dynamically

Setting IFrame height dynamically

         

Atiq

3:49 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



I am using an IFRAME in my web page.
I am calling different web pages (third party) into my IFRAME when user clicks on different menu items.

Now some pages are bigger then my IFRAME so the scroller showw up. I don't want horizental scroll in any case.As i searched i found that there is no way we can disable horizental scoll in IFRAME :(

So what i did is that i put my iframe in div and for that div I only allowed verticala sc roll to be shown.

But now there is a problem i need to set the height of the IFRAME so that i can see the whole page vertically.

But as those are third part pages i am not able to find the height and then seeting it to the IFRMAE.

Belwo is the code:

function resizeIframe() {
i_frame = parent.document.getElementById('right_frame')i_frame_Height = document.body.scrollHeight
i_frame.style.height = i_frame_Height+300+ "px"
}

'right_frame' is id for my IFRAME.

I am calling this function on body load.
I know above is wrong as it will always give me my body's height and i need the body height of the page which is contianed by IFRMAE.

Please help!

Regards,
Atiq

orion_rus

10:31 pm on Feb 15, 2005 (gmt 0)

10+ Year Member



U can access to a height of iframe with CSS0.
<iframe name="myframe" > </iframe>
<script>
myframe.document.body.style.height="150"; //inner body height
myframe.style.height="150"; //iframe height
<script>
Good luck to you

jimbeetle

11:02 pm on Feb 15, 2005 (gmt 0)

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



I was fiddling with this about a year ago, then decided to go in a different direction and didn't pursue it to the end.

Yep, you can't access the height of the off-site page. I banged my head around this and finally found a technique through Googling, unfortunately I can't find the site and forget the specifics.

But what it involved was first pulling the external page into a local container (div maybe?) from which you can then grab the height and go from there.

I know this isn't much help, but it might give you or somebody else a jumping off point to a solution.

Atiq

7:29 am on Feb 17, 2005 (gmt 0)

10+ Year Member



I am trying my options out but it is very strange that we can not disable the horizenatl scroll ber of an IFRAME.

If I could have done it i could have save lot of my time. :) :)

Please if any one the better solution please advise.