forked from twbs/bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathiframe_higher.html
More file actions
60 lines (60 loc) · 1.7 KB
/
iframe_higher.html
File metadata and controls
60 lines (60 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gbk">
<title>iframe高于页面实际高度</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css">
<style>
body{font:12px/1.5 "宋体";}
table{ border:1px solid #ccc; border-width:1px 0 0 1px; border-collapse:collapse;}
th,td{ padding:4px 15px; border:1px solid #ccc; border-width:0 1px 1px 0;}
th{ background-color:#eee;}
#frame_content_parent{ height:1800px; }
</style>
</head>
<body>
<table>
<thead>
<tr>
<th></th>
<th>IEs</th>
<th>Firefox</th>
<th>opera</th>
<th>Chrome、safari</th>
</tr>
</thead>
<tbody>
<tr>
<th>documentElement</th>
<td>1544</td>
<td>1800</td>
<td>1800</td>
<td>0</td>
</tr>
<tr>
<th>body</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1800</td>
</tr>
</tbody>
</table>
<iframe width="790" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://demo.zhouqicf.com/js/2010/iframe_height/same_area.html" id="frame_content_parent" name="frame_content_parent"></iframe>
<script>
(function(){
var frame = document.getElementById("frame_content_parent"),
setIframeHeight = function(){
var frameContent = frame.contentWindow.document;
alert("documentElement:" + frameContent.documentElement.scrollHeight + ";body:" + frameContent.body.scrollHeight);// + ";body:" + frameContent.body.scrollHeight
};
if(frame.addEventListener){
frame.addEventListener("load",setIframeHeight,false);
}else{
frame.attachEvent("onload",setIframeHeight);
}
})();
</script>
</body>
</html>