<span style="color: #736f5c">// </span><span style="color: #736f5c;font-family: '宋体'">计算页面的实际高度,</span><span style="color: #736f5c">iframe</span><span style="color: #736f5c;font-family: '宋体'">自适应会用到
</span><span style="color: #66d9ef">function </span><span style="color: #f72671">calcPageHeight</span><span style="color: #ffffff">(</span><span style="color: #bf9bf8">doc</span><span style="color: #ffffff">) {
</span><span style="color: #66d9ef">var </span><span style="color: #a6e22e">cHeight </span><span style="color: #f72671">= </span><span style="color: #6ccab8;font-weight: bold">Math</span><span style="color: #ffffff">.</span>max<span style="color: #ffffff">(</span><span style="color: #bf9bf8">doc</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">body</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">clientHeight</span><span style="color: #ffffff">, </span><span style="color: #bf9bf8">doc</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">documentElement</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">clientHeight</span><span style="color: #ffffff">)
</span><span style="color: #66d9ef">var </span><span style="color: #a6e22e">sHeight </span><span style="color: #f72671">= </span><span style="color: #6ccab8;font-weight: bold">Math</span><span style="color: #ffffff">.</span>max<span style="color: #ffffff">(</span><span style="color: #bf9bf8">doc</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">body</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">scrollHeight</span><span style="color: #ffffff">, </span><span style="color: #bf9bf8">doc</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">documentElement</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">scrollHeight</span><span style="color: #ffffff">)
</span><span style="color: #66d9ef">var </span><span style="color: #a6e22e">height  </span><span style="color: #f72671">= </span><span style="color: #6ccab8;font-weight: bold">Math</span><span style="color: #ffffff">.</span>max<span style="color: #ffffff">(</span><span style="color: #a6e22e">cHeight</span><span style="color: #ffffff">, </span><span style="color: #a6e22e">sHeight</span><span style="color: #ffffff">)
</span><span style="color: #66d9ef">return </span><span style="color: #a6e22e">height
</span><span style="color: #ffffff">}
</span><span style="color: #736f5c">//</span><span style="color: #736f5c;font-family: '宋体'">根据</span><span style="color: #736f5c">ID</span><span style="color: #736f5c;font-family: '宋体'">获取</span><span style="color: #736f5c">iframe</span><span style="color: #736f5c;font-family: '宋体'">对象
</span><span style="color: #66d9ef">var </span><span style="color: #a6e22e">ifr </span><span style="color: #f72671">= </span><span style="color: #6ccab8;font-weight: bold">document</span><span style="color: #ffffff">.</span><span style="color: #6ccab8">getElementById</span><span style="color: #ffffff">(</span><span style="color: #ffe792">'main'</span><span style="color: #ffffff">)
</span><span style="color: #a6e22e">ifr</span><span style="color: #ffffff">.</span><span style="color: #6ccab8">onload </span><span style="color: #f72671">= </span><span style="color: #66d9ef">function</span><span style="color: #ffffff">() {
</span><span style="color: #736f5c">//</span><span style="color: #736f5c;font-family: '宋体'">解决打开高度太高的页面后再打开高度较小页面滚动条不收缩
</span><span style="color: #a6e22e">ifr</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">style</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">height</span><span style="color: #f72671">=</span><span style="color: #ffe792">'0px'</span><span style="color: #ffffff">;
</span><span style="color: #66d9ef">var </span><span style="color: #a6e22e">iDoc </span><span style="color: #f72671">= </span><span style="color: #a6e22e">ifr</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">contentDocument </span><span style="color: #f72671">|| </span><span style="color: #a6e22e">ifr</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">document
</span><span style="color: #66d9ef">var </span><span style="color: #a6e22e">height </span><span style="color: #f72671">= calcPageHeight</span><span style="color: #ffffff">(</span><span style="color: #a6e22e">iDoc</span><span style="color: #ffffff">)
</span><span style="color: #66d9ef">if</span><span style="color: #ffffff">(</span><span style="color: #a6e22e">height </span><span style="color: #f72671">< </span><span style="color: #66d9ef">850</span><span style="color: #ffffff">){
</span><span style="color: #a6e22e">height </span><span style="color: #f72671">= </span><span style="color: #66d9ef">850</span><span style="color: #ffffff">;
</span><span style="color: #ffffff">    }
</span><span style="color: #a6e22e">ifr</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">style</span><span style="color: #ffffff">.</span><span style="color: #6ccab8;font-weight: bold">height </span><span style="color: #f72671">= </span><span style="color: #a6e22e">height </span><span style="color: #f72671">+ </span><span style="color: #ffe792">'px'
</span><span style="color: #ffffff">}</span>