Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

IFRAME autosizes and DIV autoload.

0 views
Skip to first unread message

alejandro.rivero

unread,
Nov 7, 2003, 9:05:10 AM11/7/03
to
In Mozilla, the following code seems to resize correctly the IFRAME,
so no scroll bars:

<iframe marginwidth=0 marginheight=0 src=text.html
onload="this.height=
this.contentDocument.height">
</iframe>

Of course a frameborder=0 can be desiderable too :-)

Also, the same trick simplifies DIV loading:

<div id=pie></div>
<iframe
onload="document.getElementById('pie').innerHTML=
this.contentDocument.body.innerHTML"
scrolling=no width=100% height=1% frameborder=0 style="visibility:hidden"
src=text.html>
here the this.innerHTML, which is not transferred
</iframe>

Regretly, the onload tag does not work in konqueror.

Roger Keays

unread,
Nov 17, 2003, 6:39:57 AM11/17/03
to
> <iframe marginwidth=0 marginheight=0 src=text.html
> onload="this.height=
> this.contentDocument.height">
> </iframe>

I get

Error: uncaught exception: Permission denied to get property HTMLDocument.height

when trying this with Mozilla (?)

Love to see it work though...


--
-------------------------------------------------------------
ninth ave p: +61 7 3870 8494
_ _ _ m: +61 405 048 371
__(@)< __(@)> __(@), w: http://www.ninthave.net
\___) \___) \___) e: r.k...@ninthave.net
-------------------------------------------------------------

alejandro.rivero

unread,
Nov 17, 2003, 8:44:36 AM11/17/03
to
Roger Keays <r.k...@ninthave.net> wrote in message news:<3fb8b43c$0$13673$afc3...@news.optusnet.com.au>...

> > <iframe marginwidth=0 marginheight=0 src=text.html
> > onload="this.height=
> > this.contentDocument.height">
> > </iframe>
>
> I get
>
> Error: uncaught exception: Permission denied to get property HTMLDocument.height
>
> when trying this with Mozilla (?)

Hmm. Intriguing. My version of Mozilla is
Mozilla 1.4
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030908 Debian/1.4-4


I have a page (http://cgt.unizar.es/jornadas/) with the resizing code in
an extended version, and it works:
<iframe
onload="this.height=this.contentDocument.height;
this.contentDocument.body.style.borderStyle='none';
this.contentDocument.body.style.marginTop=0;
this.contentDocument.body.style.marginBottom=0;
this.contentDocument.body.style.paddingBottom=0;
this.contentDocument.body.style.paddingTop=0;"
onclick="this.height= this.contentDocument.height"
scrolling=auto width=100% height=0 frameborder=0
src=punterosSL.html>
Tu browser no soporta iframes. Carga directamente el
<a href=punterosSL.html>fichero</a>
</iframe>

except for the onclick :-( But the onload does its work perfectly.
All the other stuff, btw, is just to avoid the vertical scroll bar nuissance.

Wired Earp

unread,
Nov 17, 2003, 11:46:08 AM11/17/03
to
alejandro.rivero wrote:

>>> <iframe onload="this.height=this.contentDocument.height"/>


>> Error: uncaught exception: Permission denied to get property
>> HTMLDocument.height

DHTML and HTML are practically unrelated disciplines, please see
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html. Also check out your
cross-site-scripting privleges. And use real properties:

this.setAttribute ( "height", this.contentDocument.
getElementsByTagName ( "body" ).item ( 0 ).
offsetHeight );

> All the other stuff, btw, is just to avoid the
> vertical scroll bar nuissance.

To handle this in Mozilla, style the content-documents:

:root {
overflow: moz-scrollbars-horizontal;
height: 100%;
}

Explorer has an overflow-x property to check. Both browsers support
adding these styles by force.

>>> Regretly, the onload tag does not work in konqueror.

Tapping into iframe events is badly supported in most browsers. Perhaps
You can pass the information from content-document to the surrounding
enviroment for wider browser support.

window.addEventListener ( "load", function () {
top.yourResizeFunction ( document.body.offsetHeight );
}, false );

--
Wired Earp
Wunderbyte

Roger Keays

unread,
Nov 20, 2003, 2:12:42 AM11/20/03
to

Can anybody do this in IE ? (autosize an iframe that is).

Wired Earp wrote:
> alejandro.rivero wrote:
>
>
>>>> <iframe onload="this.height=this.contentDocument.height"/>
>>>
>>>Error: uncaught exception: Permission denied to get property
>>>HTMLDocument.height

Yeh, it only works for pages from the same domain. :(

>
>
> DHTML and HTML are practically unrelated disciplines, please see
> http://www.cs.tut.fi/~jkorpela/usenet/xpost.html. Also check out your
> cross-site-scripting privleges. And use real properties:
>
> this.setAttribute ( "height", this.contentDocument.
> getElementsByTagName ( "body" ).item ( 0 ).
> offsetHeight );
>
>
>>All the other stuff, btw, is just to avoid the
>>vertical scroll bar nuissance.
>
>
> To handle this in Mozilla, style the content-documents:
>
> :root {
> overflow: moz-scrollbars-horizontal;
> height: 100%;
> }
>
> Explorer has an overflow-x property to check. Both browsers support
> adding these styles by force.
>
>
>>>>Regretly, the onload tag does not work in konqueror.
>
>
> Tapping into iframe events is badly supported in most browsers. Perhaps
> You can pass the information from content-document to the surrounding
> enviroment for wider browser support.
>
> window.addEventListener ( "load", function () {
> top.yourResizeFunction ( document.body.offsetHeight );
> }, false );
>
>
>


--

0 new messages