473,791 Members | 2,853 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Maximise size of iFrame

OK. Now I'm all googled out and still puzzled !

I admit I am very new to javascript, but think that it is the only solution
to this.

I have a web page with a table ( 2 columns, 1 row )

The left cell width is set at 150px
The right cell at 100%

The right cell contains an iFrame. The iFrame width is 100% & height 100%

This is what I want to happen :

I don't want scroll bars either on the right or bottom.
When the browser is resized, the left cell width remains unchanged, but the
height adjusts to the browsers height. Works fine.
The right cell resizes fine.
The iFrame does not.
If I set the iFrame width to 100% and height to 100%, the width resizes but
the height doesn't change.
If I set the iFrame height as a numeric value ( eg.. height=300 ) it changes
to that size.

After googling, I found this :

function changeIframe()
{
var new_height = document.getEle mentById('table 1').height;
document.getEle mentById('cFram e1').height = new_height;
}
window.onresize = changeIframe;
</script>

I understand that this --should-- read the height from the table and set the
iFrame height using this value.

However, the table's height is "100%" and I think that I need to get the
height in pixels as the iFrame appears to ignore '%' for height values.

Any suggestions most welcome.

Regards
DaveO
Jul 23 '05 #1
2 6147
DaveO wrote:
I admit I am very new to javascript, but think that it is the only
solution to this.
It is not a solution at all here.
I have a web page with a table ( 2 columns, 1 row )
The left cell width is set at 150px
The right cell at 100%
IOW: You have a deprecated table layout rather than a recommended
style sheets layout. Apparently you have slept for, say, the last
five years or had a very bad teacher or documentation at your hands.
The right cell contains an iFrame. The iFrame width is 100% & height 100%

This is what I want to happen :

I don't want scroll bars either on the right or bottom.
Use CSS:

overflow:hidden ;

Although I would not recommend that: users want to scroll when necessary.
When the browser is resized, the left cell width remains unchanged, but
the height adjusts to the browsers height. Works fine.
The right cell resizes fine.
The iFrame does not.
Why should it? 100% of positioned parent (table cell) is 100% of the
table cell, not 100% of the viewport. The chicken-and-the-egg problem
here is that the table cell is as high as the united maximum height of
its positioned childs which happens to be the height of the `iframe'
element only here; this is why formatting the child element with 100%
height does not change anything.

Therefore, you have to drop tables (*g*), format the `body' element
position:absolu te and of maximum height (use `right' and `bottom'
properties where supported, `width' and `height' where not), have two
block elements float around each other using all available height (of
the positioned parent) and format the `iframe' as child of the second
floating block element accordingly. Good luck.
If I set the iFrame width to 100% and height to 100%, the width resizes
but the height doesn't change.
If I set the iFrame height as a numeric value ( eg.. height=300 ) it
changes to that size.
Of course.
After googling, I found this :

function changeIframe()
{
var new_height = document.getEle mentById('table 1').height;
document.getEle mentById('cFram e1').height = new_height;
}
window.onresize = changeIframe;


Junk code that does not work if client-side script support is
absent or disabled.
PointedEars
--
When you have eliminated all which is impossible, then
whatever remains, however improbable, must be the truth.
-- Sherlock Holmes
Jul 23 '05 #2
DaveO wrote:
I admit I am very new to javascript, but think that it is the only
solution to this.
It is not a solution at all here.
I have a web page with a table ( 2 columns, 1 row )
The left cell width is set at 150px
The right cell at 100%
IOW: You have a deprecated table layout rather than a recommended
style sheets layout. Apparently you have slept for, say, the last
five years or had a very bad teacher or documentation at your hands.
The right cell contains an iFrame. The iFrame width is 100% & height 100%

This is what I want to happen :

I don't want scroll bars either on the right or bottom.
Use CSS:

overflow:hidden ;

Although I would not recommend that: users want to scroll when necessary.
When the browser is resized, the left cell width remains unchanged, but
the height adjusts to the browsers height. Works fine.
The right cell resizes fine.
The iFrame does not.
Why should it? 100% of positioned parent (table cell) is 100% of the
table cell, not 100% of the viewport. The chicken-and-the-egg problem
here is that the table cell is as high as the united maximum height of
its positioned children which happens to be the height of the `iframe'
element only here; this is why formatting the child element with 100%
height does not change anything.

Therefore, you have to drop tables (*g*), format the `body' element
position:absolu te and of maximum height (use `right' and `bottom'
properties where supported, `width' and `height' where not), have two
block elements float around each other using all available height (of
the positioned parent) and format the `iframe' as child of the second
floating block element accordingly. Good luck.
If I set the iFrame width to 100% and height to 100%, the width resizes
but the height doesn't change.
If I set the iFrame height as a numeric value ( eg.. height=300 ) it
changes to that size.
Of course.
After googling, I found this :

function changeIframe()
{
var new_height = document.getEle mentById('table 1').height;
document.getEle mentById('cFram e1').height = new_height;
}
window.onresize = changeIframe;


Junk code that does not work if client-side script support is
absent or disabled.
PointedEars
--
When you have eliminated all which is impossible, then
whatever remains, however improbable, must be the truth.
-- Sherlock Holmes
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9306
by: Catherine Lynn Smith | last post by:
I want to know the recommended way to handle scripting of/with containers such as an iframe. I have a page with border-navigation bars on the top/bottom/left/right and I want to use an iframe to load content in the middle. I would like, if possible, to have the parent window resize itself to suit whatever is loaded into the iframe container, deriving the size needed from calculated values. Thus the calculation would have to over-ride...
3
4882
by: Bootstrap bill | last post by:
I have an iframe embedded in a single cell table. I'd like to resize the table and iframe to match any changes made to window size. Is this possible? -- "It's easy enough to be pleasant, when life hums along like a song. But the man worth while is the man who can smile when everything goes dead wrong.".
6
5746
by: gsb | last post by:
Don't know if this is the right place to post this JavaScript issue. If not, could someone point me in the right direction please. I am trying to make a "cross browser compliant" floating iFrame. Not real fancy, just load, resize and move. But, I do not have the browsers, OSs and different machines (like Mac) to test the code on. So I need some help to see where this basic example of works and does not work.
3
6750
by: coolsti | last post by:
I need some help here. I am making an application which allows a user to look at a series of picture files one at a time, and enter the outcome of various visual tests to a database. The application is based on mysql and php on a remote server, and is accessed by the user via a web browser, primarilly IE. The image file names are built up by the server side php scripts, and so a URL for the image file is created, but the file itself is...
1
3287
by: Matt S | last post by:
I have an advertiser that delivers content in an iFrame. Because of space limitations on my page, I have set the height of the iFrame to be half that of it's contents. The problem is that the width of the iFrame is 960. That means the vertical scrollbar on the right side appears off screen for a lot of people. Is it possible for me to switch the scrollbar from the right side of the iFrame to the left side without having access to the...
4
4484
by: tamasumalta | last post by:
I am just new to vb.net. I used to program in vb 6. Can you kindly indicate how I can maximise a form window to full in runtime. I think this is a standard thing to design controls. If this is not available then I have to drag the corners to try and match the size for designing and setting up the controls. Altough ticking the option "Maximised" for the field WindowState, this doesn't have an effect in runtime and therefore controls can't...
0
7772
by: tequilamala | last post by:
I have an Iframe in one of the pages i am developing... the iframe is suppose to scroll up and down and the links target the iframe. the problem is that the iframe scrolls side to side on internet explorer but not on firefox. I dont want it to scroll sideways. in index.htm the iframe is at the bottom of the code. index.htm <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">...
1
8137
by: Z1P2 | last post by:
I would like to gradually resize an iframe in an onmouseover event. I can easily do it with an image, but when I try to do it with an iframe, it doesn't do anything. So first of all, is it possible to gradually zoom an iframe, and if so, what am I missing? Here is the script I am trying to manipulate, between the head tags: <script language=JavaScript> /**** adjust these two parameters to control how fast or slow
3
2927
by: matwilko | last post by:
hi, i am trying to create a simple version of itunes...and i am using iframes to do this. I have already set up the iframes using dreamweaver and used a drop-down menu to select the genre. When selecting the genre the artists appears in iframe1...and i want to be able to select the artist so that the songs appear. I am unsure of how to do this, could anybody help? Thanks Here is my current code... <html> <head> <title>MiTunes</title>...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.