内部のコンテンツが変更された後、iframe の高さを更新する方法はありますか?
例: http://thc-racing.ucoz.com/index/forum/0-14
私はeasyXDMを使用しています
ページコード:
<script type="text/javascript" src="http://thc-racing.ucoz.com/design/forum-external/xdm/easyXDM.js"></script>
<div id="page-body">
<!-- do not define an iframe, it will get generated for you in this container -->
</div>
<script type="text/javascript">
new easyXDM.Socket({
remote: "http://thc-racing.forumotion.co.uk/",
container: document.getElementById("page-body"),
onMessage: function(message, origin){
this.container.getElementsByTagName("iframe")[0].style.height = message + "px";
this.container.getElementsByTagName("iframe")[0].style.width = "900px";
}
});
</script>
iFrame ページ:
<script type="text/javascript" src="http://thc-racing.ucoz.com/design/forum-external/xdm/easyXDM.js"></script>
<script type="text/javascript">
var socket = new easyXDM.Socket({
onReady: function() {
// this is needed for setting height on initial load
socket.postMessage(document.body.scrollHeight)
},
onMessage: function(message, origin){
// this is called from consumer (maybe by a timer)
socket.postMessage(document.body.scrollHeight)
}
});
</script>
ありがとう。