留言板

Function to Auto Resize in Alloy

Sofia Lucas,修改在9 年前。

Function to Auto Resize in Alloy

New Member 帖子: 13 加入日期: 14-6-12 最近的帖子
Hello Community,
I need to convert this script to AUI JS which I've never used before. My script below aims to resize an iframe on Liferay depending on the content :

<script language="javascript" type="text/javascript">
  function resizeIframe(obj) {
    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
  }
</script>


Can I get some help from you ?

Regards,
Sofia.
thumbnail
David H Nebinger,修改在9 年前。

RE: Function to Auto Resize in Alloy

Liferay Legend 帖子: 14917 加入日期: 06-9-2 最近的帖子
Simple JS does not require conversion to alloy.
Sofia Lucas,修改在9 年前。

RE: Function to Auto Resize in Alloy

New Member 帖子: 13 加入日期: 14-6-12 最近的帖子
Thank you for the reply. I m using this script(as it is ) , and in the Html Attributes of my page , I add this line :

onload="resizeIframe(#portlet_48_INSTANCE_NhIc03Ne857c)"


PS : #portlet_48_INSTANCE_NhIc03Ne857c is the Id of my Iframe portlet.

But it doesn't work, the Iframe doesn't auto-resize .
thumbnail
David H Nebinger,修改在9 年前。

RE: Function to Auto Resize in Alloy

Liferay Legend 帖子: 14917 加入日期: 06-9-2 最近的帖子
First, you shouldn't be using onload. Liferay has facilities you should be using, i.e. Liferay.on('AllPortletsReady', function() {}); See https://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/javascript.

Second, #portlet_blah_blah_blah is not an object, it is merely an id. Objects are found at least by using getElementById() or AUI's facilities to find an element. Your passing who knows what as the argument, but that thing does not have the ability to resize.
Sofia Lucas,修改在9 年前。

RE: Function to Auto Resize in Alloy

New Member 帖子: 13 加入日期: 14-6-12 最近的帖子
Ok I got it , I made a mistake by giving the Id of the Iframe as argument to the function which needs an object instead . And I ll try to rectify the script .
Thank you .

Regards,
Sofia.