473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Struggling with setting iframe height dynamically

DL
That is, for an iframe with onload attribute to preset a width and
height then depending on the length of its content to auto-expand
instead of scrolling. The following URL is quite interesting,
http://www.phpmix.org/iframe_height_auto_resize,
however, it failed to work for me, OS = XP w/ sp2; brower = IE7, but
my app is quite complicated... it load the iframe inside a javascrip-
driven window...

And their forum has been closed, so, I have to post the question here,
the thrown js error is, "DYNIFS not defined". Any idea on a solution
would be appreciated.

tia.
Aug 30 '08 #1
9 2500
The obvious question is did you download the JS file and reference it
properly in your code?

John

DL wrote:
That is, for an iframe with onload attribute to preset a width and
height then depending on the length of its content to auto-expand
instead of scrolling. The following URL is quite interesting,
http://www.phpmix.org/iframe_height_auto_resize,
however, it failed to work for me, OS = XP w/ sp2; brower = IE7, but
my app is quite complicated... it load the iframe inside a javascrip-
driven window...

And their forum has been closed, so, I have to post the question here,
the thrown js error is, "DYNIFS not defined". Any idea on a solution
would be appreciated.

tia.
Aug 31 '08 #2
DL
On Aug 31, 11:36*am, john6630 <john6...@hotmail.comwrote:
The obvious question is did you download the JS file and reference it
properly in your code?

John
Yes, but on "reference it properly" it could be an issue, the IFRAME
that I have IS NOT reloaded, the code is like this
<iframe id="frame1" name="frame1"
onload="document.frames['frame1'].document.designMode='on';"
contenteditable="true" style="width:600px; height:280px;"><font
size="-1"></font></iframe>

And it has to be this way to accomodate some wysiwug editor that I
'cook' up.

Further thoughts? Thanks.
Aug 31 '08 #3
On Aug 31, 2:24 pm, DL <tatata9...@gmail.comwrote:
On Aug 31, 11:36 am, john6630 <john6...@hotmail.comwrote:The obvious question is did you download the JS file and reference it
properly in your code?
John

Yes, but on "reference it properly" it could be an issue, the IFRAME
that I have IS NOT reloaded, the code is like this
<iframe id="frame1" name="frame1"
onload="document.frames['frame1'].document.designMode='on';"
contenteditable="true" style="width:600px; height:280px;"><font
size="-1"></font></iframe>

And it has to be this way to accomodate some wysiwug editor that I
'cook' up.

Further thoughts? Thanks.
I do not see any call to the javascript

"DYNIFS.resize('frame1')"

I think you need this in the onload event to allow it to resize. Not
sure how it works with respect to the style settings you are using.
But you should be able to use trial and error to work it out.

John
Sep 1 '08 #4
DL
>
I do not see any call to the javascript

"DYNIFS.resize('frame1')"

I think you need this in the onload event to allow it to resize. Not
sure how it works with respect to the style settings you are using.
But you should be able to use trial and error to work it out.

John- Hide quoted text -
Sorry, I forgot to mention that I did add the call element of
"DYNIFS.resize('frame1')" inside the onload event to no avail.
Interesting thought on interaction with style settings.

The main page has the following inline style settings:
<style type="text/css">
#projectautosuggest {
z-index:10;
}
body, p, div, th, td
{
font-family: Verdana,Tahoma, sans-serif,Arial, Helvetica;
font-size: 10pt;
}
</style>
while the page that hosts the iframe has not any. My concern is this
app has quite a bit of third party js libraries, maybe they cause
confusion... A thought of trying it with Firefox's Firebug is quickly
abandoned because current FireFox (v2 or v3) does not support the
onload event for iframe. hmm, am I stuck?

Thanks.
Sep 1 '08 #5
DL wrote:
[...]
<iframe id="frame1" name="frame1"
onload="document.frames['frame1'].document.designMode='on';"
contenteditable="true" style="width:600px; height:280px;"><font
size="-1"></font></iframe>
[...]
A thought of trying it with Firefox's Firebug is quickly
abandoned because current FireFox (v2 or v3) does not support the
onload event for iframe. *
And it also doesn't support 'contenteditable' and
'document.designMode'. I would probably do something like this:

<iframe id="frame1" height="100"></iframe>
<input type="button" value="Resize"
onClick="document.getElementById('frame1').height= '200px';">

Hope this helps,

--
Bart
Sep 1 '08 #6
DL
On Sep 1, 11:31*am, Bart Van der Donck <b...@nijlen.comwrote:
DL wrote:
[...]
<iframe id="frame1" name="frame1"
onload="document.frames['frame1'].document.designMode='on';"
contenteditable="true" style="width:600px; height:280px;"><font
size="-1"></font></iframe>
[...]
A thought of trying it with Firefox's Firebug is quickly
abandoned because current FireFox (v2 or v3) does not support the
onload event for iframe. *

And it also doesn't support 'contenteditable' and
'document.designMode'. I would probably do something like this:

* *<iframe id="frame1" height="100"></iframe>
* *<input type="button" value="Resize"
* * onClick="document.getElementById('frame1').height= '200px';">

Hope this helps,

--
*Bart
Bart,

I've tried your following approach before to no avail.
<input type="button" value="Resize"
onClick="document.getElementById('frame1').height= '200px';">
Debugging out = {empty string}
Have also tried a similar one like
<input type="button" value="Resize"
onClick="document.frames('frame1').height='200px'; ">
Debugging out = undefined

Isn't there a way to call the named or IDed frame within the current
window?

Thanks.

Sep 2 '08 #7
DL wrote:
Bart,

I've tried your following approach before to no avail.
( <iframe id="frame1" height="100"></iframe)
<input type="button" value="Resize"
* * onClick="document.getElementById('frame1').height= '200px';">
Not sure why this would not work for you. Please make sure that there
is only one id="frame1" and that the <iframeis also present on the
web page.
Debugging out = {empty string}
Have also tried a similar one like
*<input type="button" value="Resize"
* * onClick="document.frames('frame1').height='200px'; ">
Debugging out = undefined
The document.frames object doesn't have a 'height'-property, so this
approach cannot be used. FireFox seems to have a 'innerHeight', but
MSIE doesn't.

By the way, you cannot refer to a frame in this way. It should be:

frames['iframe1']

and not

document.frames('frame1')
Isn't there a way to call the named or IDed frame within the current
window?
Sure. For ID: please see my previous example with 'getElementById'.
For name: it makes no sense to refer by name using document.frames,
because it has no height-property that is well supported.

Here is a way without ID or name:

<iframe height="100"></iframe>
<input type="button" value="Resize"
onClick="document.getElementsByTagName('iframe')
[0].height='200px';">

Hope this helps,

--
Bart
Sep 2 '08 #8
On or about 8/30/2008 17:37, it came to pass that DL wrote:
That is, for an iframe with onload attribute to preset a width and
height then depending on the length of its content to auto-expand
instead of scrolling. The following URL is quite interesting,
http://www.phpmix.org/iframe_height_auto_resize,
however, it failed to work for me, OS = XP w/ sp2; brower = IE7, but
my app is quite complicated... it load the iframe inside a javascrip-
driven window...

And their forum has been closed, so, I have to post the question here,
the thrown js error is, "DYNIFS not defined". Any idea on a solution
would be appreciated.

tia.
I struggled with this issue a few years back and eventually gave up. I
had it working if it was within the same domain, but when it was across
two separate domains I bumped into browser cross domain restrictions and
it refused to work, even for something (IMHO) as innocuous as setting
the IFrame height.

Since my site was supposed to provide the Iframe to numerous foreign
sites, I wrote a PHP script that generates Javascript filling in a Div
eliminating all the Iframe issues.

Quick example on how to do this

On source page on any domain: www.foobar.com/extermalcontent.html

<div id='ContentDiv'>
<noscript><b>*****WARNING JAVASCRIPT IS DISABLED, IT MUST BE ENABLED TO
PROPERLY VIEW THIS PAGE*****</b>
</noscript>
....Loading content from EXAMPLE.ORG...
</div>
<script type="text/javascript"
src="http://www.example.org/ExternalContent.php?parm1=sample>
</script>

The PHP script generates javascript:
function SetDiv()
{
document.getElementById('ContentDiv').innerHTML = '<p>whatever you want</p>'
}
Sep 2 '08 #9
DL
On Sep 2, 3:53*am, Bart Van der Donck <b...@nijlen.comwrote:
DL wrote:
Bart,
I've tried your following approach before to no avail.
( <iframe id="frame1" height="100"></iframe)
<input type="button" value="Resize"
* * onClick="document.getElementById('frame1').height= '200px';">

Not sure why this would not work for you. Please make sure that there
is only one id="frame1" and that the <iframeis also present on the
web page.
Debugging out = {empty string}
Have also tried a similar one like
*<input type="button" value="Resize"
* * onClick="document.frames('frame1').height='200px'; ">
Debugging out = undefined

The document.frames object doesn't have a 'height'-property, so this
approach cannot be used. FireFox seems to have a 'innerHeight', but
MSIE doesn't.

By the way, you cannot refer to a frame in this way. It should be:

* frames['iframe1']

and not

* document.frames('frame1')
Isn't there a way to call the named or IDed frame within the current
window?

Sure. For ID: please see my previous example with 'getElementById'.
For name: it makes no sense to refer by name using document.frames,
because it has no height-property that is well supported.

Here is a way without ID or name:

* *<iframe height="100"></iframe>
* *<input type="button" value="Resize"
* * onClick="document.getElementsByTagName('iframe')
[0].height='200px';">

Hope this helps,

--
*Bart
I truly appreciate your efforts but it won't work. I have long
suspected the bloated YUI etc. etc. third party js libararies mess
things up (the app can't do without them). At this point I'll give it
up for now... this feature would be nice to have but not super
Critical...
Sep 3 '08 #10

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

Similar topics

12
by: Javier | last post by:
Hello, I'm very new in this forum and as I have the following problem, the website is in http://new.vanara.com ----------------------------------------------------------------------------...
4
by: Thomas | last post by:
Hi there, I have an iframe which is editable (designMode = "on") and want to resize it dynamically as the content grows (e.g. more lines of text is in there) and there the struggle starts. I...
2
by: Sticky | last post by:
I really need some help - i have already pulled out 1/2 my hear and the rest is following quickly..... I am designing a page containing an iFrame, the contents of which are selected dynamically...
3
by: visu | last post by:
Hi , I need a solution for my problem with IFRAME in firefox. The problem is that i ve to make the IFRAME to increase in its height to displays its whole content dynamically .i ve set...
4
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using a I frame in a page and trying to set the height to height=100% and it is not working. If I use height=600px it works. I find some stuff about the DOCTYPE on the internet but changing...
3
by: Jills | last post by:
Hi All, Does anyone have any idea about how can we resize an IFRAME dynamically according to its content from another domain? I want to increase the height according to the page that is...
1
by: chaitanyadotcom | last post by:
As per my application i need to create tabs using iFrame dynamically. There are totally 4 buttons in my application where for each button i provide a link. Where in it will dynamically create a tab...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.