跨域Iframe實現高度自適應:
<html>
<head>
<style>
body {margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
overflow: hidden
}
</style>
</head>
<body>
<iframe src='http://baidu.com/' width='100%' height='100%' frameborder='0' name="_blank" id="_blank" > </iframe>
</body>
</html>
注意三點.
1. 文件開頭不能是:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
必須 是<html>開頭
2. body樣式中的 overflow: hidden; 絕對不對省略;
3.Iframe 中的 height='100%' 以及 滾動條不能設爲no(默認是yes,不用設置即可)