Foros de discusión

IFrame scrollbar

thumbnail
Kevin Jebel, modificado hace 13 años.

IFrame scrollbar

Junior Member Mensajes: 80 Fecha de incorporación: 27/05/10 Mensajes recientes
Hello,

I'd like to remove the scrollbar of my iframe. I'd like the height of the iframe increases when it needs.
I hope I am clear enough.

Thanks,
Kevin.
thumbnail
Kevin Jebel, modificado hace 13 años.

RE: IFrame scrollbar

Junior Member Mensajes: 80 Fecha de incorporación: 27/05/10 Mensajes recientes
Any suggestion ?
thumbnail
Prakash Khanchandani, modificado hace 13 años.

RE: IFrame scrollbar

Expert Mensajes: 329 Fecha de incorporación: 10/02/11 Mensajes recientes
My reply is quite late, but may help somebody emoticon

As it says in the Iframe-wiki:
Note: The size of the iframe portlet will automatically adjust to the size of the HTML page displayed if this page is in the same server. However, if you set the attributes width or height it won't automatically resize.


I did some search on this and found out that this can be done only through javascript (I read about other solutions but could not implement them successfully due to a lot constraints like cache etc) and liferay also employs javascript (see the source of the <iframe onload=""> within the portlet) to change the height of the portlet according to the page within. The page on the same server means originating on the same domain.

Now, javascript has a limitation - it can't access the document properties of pages which do not share the same domain as the parent page. Why? Because it will cause a security issue (known as cross domain security) and hence browsers do not allow that and if we try to access, it does not execute and gives a warning: Permission denied for <localhost:8080 [our page]> to get property HTMLDocument.body from <http://www.google.co.in [the external domain site]>.

So in short it is not possible to resize according to the content of the page for cross domain or third party sites within an iFrame Portlet, though if you have control over the third party pages you can achieve this even if the pages are cross domain. By control I mean if you can edit the pages and insert scripts in those pages then it could be done.

Some References:
1) easyXDM javascript api to communicate in a cross domain fashion
2) This blog explains the issue and provides the easyXDM solution for it.
3) This site has a script for same domain resizing, somewhat similar in use with liferay's script.
4) HTML5 could help you too, if you have control over the cross domain pages.

I have yet to come across a solution through which we can get the content height without manipulating the pages (cross domain) within the <iframe> tag.

Hope this helps. emoticon

If there are any other suggestions and/or some workable code to do this cross domain way, then please post it.

Thanks
thumbnail
Baptiste Grenier, modificado hace 13 años.

RE: IFrame scrollbar

Regular Member Mensajes: 100 Fecha de incorporación: 30/06/09 Mensajes recientes
You could be interested by this messages from Corné:
http://www.liferay.com/community/forums/-/message_boards/message/5899370

I did a different thing regarding the resize: I resize the iFrame (using JavaScript) in order for it to take all the vertical space available in the viewport of the browser minus a small margin.
thumbnail
Nicolas Forney, modificado hace 12 años.

RE: IFrame scrollbar

Junior Member Mensajes: 78 Fecha de incorporación: 23/05/11 Mensajes recientes
Hi,

If it can still help I developped an IFrame portlet which use the easyXDM project to handle cross-domain resizing.

Here are the links to the portlet's repositories :
Github repository
Liferay repository

SeeU
thumbnail
Prakash Khanchandani, modificado hace 12 años.

RE: IFrame scrollbar

Expert Mensajes: 329 Fecha de incorporación: 10/02/11 Mensajes recientes
Thanks for the code will try it.