0
콘텐츠에 맞게 iframe 간 도메인의 크기를 조정해야합니다. parent.html 내가이 쓰기 그래서 : IFRAME의 크기는 어떻게 조정합니까?
$(function() {
$('iframe').load(function() {
var h = null;
if (!h) {
if (location.hash.match(/^#h(\d+)/)) {
h = RegExp.$1;
$(this).css({
'height': h + 'px'
})
location.hash = ''
}
}
})
})
및 child.html을에
내가이 쓰기 :$(function() {
h = 0
h = $(document).height()
console.log(h)
if (top != self) {
top.location.replace("http://parentdomain.com/#h" + h);
}
})
그것은 한 번에로드 할 때 잘 작동하지만 난은 iframe 및 내용 변경에 링크를 클릭하면 변수 h
에는 여전히 첫 번째 값이 있습니다. 새 창 child.html
을 열면 var h
은 변경되지만 iframe에는 변경되지 않습니다.
수정할 수 있습니까?
하지만 'h' 아이가 DOM을 사용할 준비가되었습니다. 안 그래? – rsboarder
첫 번째로드가 수행 된 후에 만 –
jQuery에 대해 많이 알지는 못하지만 iframe에 바인딩 된 onload 이벤트로 여러 번 수행했습니다. 따라서 콘텐츠가 변경 될 때마다 콘텐츠가 적합합니다 (아약스 호출의 예외;) – walialu