开发者

Faking body.scrollHeight

开发者 https://www.devze.com 2022-12-17 16:12 出处:网络
I have a JavaScript application that is being loaded in an iframe (via a Liferay portlet).The actual HTML is just an emptytag and the JS is loaded when the document is loaded.

I have a JavaScript application that is being loaded in an iframe (via a Liferay portlet). The actual HTML is just an empty tag and the JS is loaded when the document is loaded.

When Liferay loads the page in the iframe, it resizes the frame based on the body.scrollHeight property which ends up being 0 since there is no real content in the page before it is loaded.

Is there a way to to style or m开发者_如何学Codify the page in such a way that body.scrollHeight will give a reasonable value and not zero?

I've tried setting the body height to 100% and adding an   but that didn't work.


You could set a javascript event in <body onload="doStuff()"> which would then have the scrollheight poperly set when it's called.

Or set the CSS to a fixed pixel height like body { height: 250px }

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号