Home  >  Article  >  Web Front-end  >  Standard issues that come to mind when getting scrollHeight in JS_javascript skills

Standard issues that come to mind when getting scrollHeight in JS_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:12:571200browse

When I am making an iframe to automatically adjust the height, the code of the embedded page commit.asp is as follows:

Copy the code The code is as follows:





's comments



< ;/body>



Then on another page Insert other code to embed this page into other pages


But it has no effect, the iframe cannot automatically adjust the height according to the content.
Later I added alert(document.body.scrollHeight); to zoomiframe(). The value that pops up is 0, but if you run COMMIT directly. The height of the ASP pop-up is consistent with the content.
I really don’t understand what’s going on. I've been able to do this before, but I don't know if anyone on the forum has encountered this problem.
Thank you!
Copy code The code is as follows:

parent.document.all("comment_load").style .height=document.body.scrollHeight||document.documentElement.scrollHeight;

Try it, there should be no problem




Add an ID attribute

PS : If the following headers are added to the web page
Copy code The code is as follows:



You must use document.documentElement.scrollHeight for this matter
If there is no document declaration, you can use
document.body.scrollHeight
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn