0
我想獲得整個屏幕高度,直到滾動發生(內容的總高度),這裏是我嘗試的代碼,但我得到的值爲0,對於如我的猜測是,整個屏幕的高度將更加然後1400px 如何得到確切高度如何從iframe或外部div獲取滾動高度
<div id="sample">
<iframe src="https://en.wikipedia.org/wiki/Main_Page" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:100%;width:100%;position:absolute;top:0x;left:0px;right:0px;bottom:0px" height="100%" width="100%" allowfullscreen id="frame" onload="myFunction()">
</iframe>
<div style="display:block; clear:both;"></div>
</div>
<script>
function myFunction() {
var elmnt = document.getElementById("sample");
var y = elmnt.scrollHeight;
var x = elmnt.scrollWidth;
var sample = "Height: " + y + "px<br>Width: " + x + "px";
alert(sample);
}
</script>