ดีคับ ทำตั้งแต่หัวค่ำจนเช้ายังไม่ได้นอน ผมไม่เก่ง อาศัยงม ลองผิดลองถูก ไปค้นเอามาจาก google มันเป็น script auto height iframe คือ หน้า iframe ที่เราดึงมาติดเว็บเรามันจะปรับความสูงของหน้าให้อัตโนมัติ โดยที่เราไม่ต้องกดหนด ความสูงของโค้ด iframe เลย จริงๆ script ใช้งานได้เพียงแต่ว่ามันดันใช้งานได้เฉพาะดึง content ในโดเมนเดียวกันเท่านั้น ถ้าต่างโดเมนมันจะไม่ทำงาน ดูตัวอย่างตามด้านล่างคับ
อันนี้หน้าตัวอย่าง content ที่มีเนื้อหายาวมากๆ ลองเข้าไปดูคับ ผมจะดึงมาใส่ใน iframe มีสองโดเมนเพื่อทดสอบ
http://www.buildstory.com/content.html
http://www.deejaa.com/content.html 
อันนี้หน้าที่ผมใส่ code iframe กดูตัวอย่างได้เลยคับ
1.
http://www.buildstory.com/iframe_mydomain.html 
ใช้ iframe เรียกหน้า
http://www.buildstory.com/content.html 
ในโดเมนเดียวกันทำงานได้ดีมันจะ
auto height ปรับความสูงตามเนื้อหาหน้า content จริงให้เลยโค้ดเรียกแบบนี้คับ จะเห็นว่าโดเมนเดียวกัน
<iframe id = "myIframe" onload = "setIframeHeight( this.id )" width="850" height="100%" scrolling="no" src="
http://www.buildstory.com/content.html 
" frameborder="0" >
</iframe>
2. แต่
http://www.buildstory.com/iframe_otherdomain.html 
ใช้ iframe เรียกหน้า
http://www.deejaa.com/content.html 
คนละโดเมน
มันไม่ยอม auto height โค้ดเรียกแบบนี้คับ คนละโดเมน script ไม่ทำงาน
<iframe id = "myIframe" onload = "setIframeHeight( this.id )" width="850" height="100%" scrolling="no" src="
http://www.deejaa.com/content.html 
" frameborder="0" >
</iframe>
ปัญหาคือ ถ้าใช้ script นี้มันใช้ได้แต่โดเมนเดียวกันเท่านั้นมันถึงจะ auto height ให้ พอต่างโดเมนมันใช้งานไม่ได้นะคับ ผมอยากให้มันใช้งานต่างโดเมนได้ด้วยนะคับ
ท่านใดพอแก้ได้บ้างไหมคับให้มันสามารถใช้กับโดเมนอื่นได้นะคับ ขอบคุณล่วงหน้าคับ
อันนี้โค้ดในส่วนของ head ส่วน body ก็โค้ด iframe ด้านบนคับ
script type='text/javascript'>
function setIframeHeight( iframeId ) /** IMPORTANT: All framed documents *must* have a DOCTYPE applied **/
{
var ifDoc, ifRef = document.getElementById( iframeId );
try
{
ifDoc = ifRef.contentWindow.document.documentElement;
}
catch( e )
{
try
{
ifDoc = ifRef.contentDocument.documentElement;
}
catch(ee)
{
}
}
if( ifDoc )
{
ifRef.height = 1;
ifRef.height = ifDoc.scrollHeight;
/* For width resize, enable below. */
// ifRef.width = 1;
// ifRef.width = ifDoc.scrollWidth;
}
}
</script>