View Full Version : Additions to the Iframe SSI script II

05-22-2005, 12:24 PM
Script: Iframe SSI script II

Altered script works in IE but not in NS6.

Ok Just to be weird I want to put an iFrame inside some standard frames. I have created some demo pages showing what I want to do and it really explains itself so go have a play:

I have extended the script so that it resizes the iframe height any time the iframe is resized by adding the lines:

currentfr.detachEvent("onresize", readjustIframe) // Bug fix line
currentfr.attachEvent("onresize", readjustIframe)

What this boils down to is I now have a dynamic iframe that adjusts itself when you resize the top level frames. Try dragging the frame bars on the demo page.

The problem is the code I have added only works in IE. When using NS6 it doesn't work. I'm not surprised as the code I added is IE specific.

I have tried adding some NS6 code but I am unsure of the correct addEventListener event code to use. I have tried 'resize', 'onresize' and other NS events that should work, such as 'click' and 'mousedown' but they do not work.

Basically I'm stuck and don't know what to do. Maybe I am trying to change the wrong part of the code, I don't know. Please help, I have searched these fourms post for post for answers, have spent 4 hours googling and still am no closer to an answer.

coding is like been in love, soul destroying maddness 95% of the time and pretty damm sweet the rest.

05-22-2005, 05:24 PM
I've used onresize in NS7.2 and all I needed was this code:


I put that in the general flow of a script (not in a function) and used a function called refresh() to carry out my intentions. However, this method is recognized by IE6 so would be redundant in your case unless selected out in one of the usual manners, or you could use it instead of your IE specific code. One caveat with this method, FF will not allow you to do certain kinds of things onresize. A work around for that is to have the function called be a dummy function that looks like this:

function refresh(){

Then put your real code in realfunction() or whatever you want to call it. This overcomes FF's reluctance and the other browsers don't seem to mind.

05-23-2005, 04:05 AM
Thank you jscheuer1 for your help. I have changed the script and it now works fantastically.

I no longer need the IE specific code and have managed to refine the additions to the old code down to next to nothing. The only things that are new are:

A little bit of code on the page that is loaded into the iframe
The NAME attribute needs to be added to the iframe code and must match the id attribute
I changed the amount of extra height added to the iframe in FireFox 1.0+ browsers from 16 to 38. This extra height was needed as the default isn't actually enough when the underlining page forces sideways scrolling.

I have uploaded the changes to the demo site so everyone can check it out. Just drag the frame borders around and the iframe should resize automatically.


If life is like a box of chocolates then why do we spend so much time in the sun?

05-23-2005, 05:26 AM
Hmmm, I get an error in IE and FF, and less than ideal performance in FF (horizontal scrollbars & clipping), worked in IE. Here is the error (page02 line 12):
setTimeout(parent.resizeIframe(self.frames.name),1);It should be:
setTimeout("parent.resizeIframe(self.frames.name)",1);I'm not sure what will happen once this error is corrected but I imagine this function on page01 will try to run:

function resizeIframe(frameid)

Added later . . . my mistake, of sorts. The clipping and horizontal scrollbar are forced by the unwrapable hypertext link on page 02. It seems to work. The error however is real and when fixed, it still works. Go figure.

05-23-2005, 06:48 AM
I can only conclude after playing with the code a bit more that the setTimeout is not needed in this case. The 'parent.resizeIframe(self.frames.name);' command was still being executed without it and is all that is needed for this script to work.