伪造 body.scrollHeight
我有一个 JavaScript 应用程序正在 iframe 中加载(通过 Liferay portlet)。实际的HTML只是一个空标签,JS在文档加载时加载。
当 Liferay 在 iframe 中加载页面时,它会根据 body.scrollHeight 属性调整框架大小,该属性最终为 0,因为加载之前页面中没有实际内容。
有没有办法以 body.scrollHeight
给出合理值而不是零的方式设置页面样式或修改页面?
我尝试将主体高度设置为 100% 并添加
但这不起作用。
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 modify 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在
中设置一个 javascript 事件,然后在调用该事件时会自动设置滚动高度。
或者将 CSS 设置为固定像素高度,例如
body { height: 250px }
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 }