Thursday, October 13, 2016

In Touch ui in aem 6.2, Sometime page content is cut and user is unable to scroll. This happens if there is something being loaded by ajax or sometimes if there is long page even without ajax. It can be fixed by setting the iframe height again, once the inner page is loaded.

Code:

getDocHeight: function (doc) {
doc = doc || document;
// stackoverflow.com/questions/1145850/
var body = doc.body,
html = doc.documentElement;
var height = Math.max(body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight);
return height;
},
setIframeHeight: function (id) {
var ifrm = parent.document.getElementById(id);
if (ifrm) {
var doc = ifrm.contentDocument ? ifrm.contentDocument :
ifrm.contentWindow.document;
ifrm.style.visibility = 'hidden';
ifrm.style.height = "10px"; // reset to minimal height ...
// IE opt. for bing/msn needs a bit added or scrollbar appears - changed 4 px addition to 10 px due to author instance
ifrm.style.height = getDocHeight(doc) + 10 + "px";
ifrm.style.visibility = 'visible';
}
}

You can call function as setIframeHeight("ContentFrame") on page load. It will reset the iframe height and content will become scrollable.




2 comments:

  1. I am receivng error as CCweb is undefined.

    ReplyDelete
  2. that was a left over variable - uodated the script , so it should work now

    ReplyDelete

Powered by Blogger.

Followers

Best Price Amazon Portal

Amazon Best Offers