それで、私はインターネットからスクリプトを盗みました。基本的に、コンテンツに合わせて iframe のサイズを変更することになっています。
function sizeIFrame()
{
var helpFrame = jQuery("#elastic");
var innerDoc = (helpFrame.get(0).contentDocument) ? helpFrame.get(0).contentDocument : helpFrame.get(0).contentWindow.document;
helpFrame.height(innerDoc.body.scrollHeight + 35);
}
ただし、Internet Explorer では動作しないようです。iframe ソースは同じサーバー上にあるため、問題にはなりません。何が問題なのですか?iframe ID は#elastic
. これを Firefox、Chrome、Safari でテストしたところ、3 つすべてで想定どおりに動作しました。
編集
スクリプトを別のより重い jQuery ソリューションに置き換えることにしました。期待していたほど軽量ではありませんが、機能しているようです。