iframe `onload` 獲取高度邏輯有誤,導致只顯示一半內容。
function SetCwinHeight(obj, bl) {
try {
var doc = obj.contentDocument || obj.contentWindow.document;
var scrollHeight = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight);
var iht = parseInt(obj.getAttribute('iht')) || 490;
if (scrollHeight > iht && bl === "true") {
obj.style.height = (scrollHeight + 50) + 'px';
} else {
obj.style.height = iht + 'px';
}
// 寬度同理
} catch (ex) { console.error(ex); }
}
contentDocument 兼容 Firefox/Chrome,contentWindow.document 兼容 IE。Math.max(body.scrollHeight, documentElement.scrollHeight) 解決 XHTML DOCTYPE 導致 body.scrollHeight=0。getAttribute('iht'),代碼中 `ith`/`iht` 混用導致邏輯錯。